Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
# this is used populated when creating a git archive
# and when there is .git dir and/or there is no git installed
fallback_version = "9999.$Format:%h-%cs$"
fallback_version = "9999.dev99"

[tool.pytest.ini_options]
norecursedirs = [
Expand Down
2 changes: 2 additions & 0 deletions src/commoncode/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,8 @@ def _populate(self, scan_data):
##########################################################
for attr_name in self.codebase_attributes:
value = scan_data.get(attr_name)
if value == None:
continue
setattr(self.attributes, attr_name, value)

##########################################################
Expand Down
13 changes: 13 additions & 0 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from os.path import exists
from os.path import join

import attr

from commoncode.fileutils import parent_directory
from commoncode.resource import Codebase
from commoncode.resource import Resource
Expand Down Expand Up @@ -661,6 +663,17 @@ def test_VirtualCodebase_with_paths_works(self):
)
check_against_expected_json_file(results, expected_file, regen=False)

def test_VirtualCodebase_codebase_attributes_assignment(self):
test_codebase = self.get_test_loc('resource/with_path/virtual-codebase.json')
vc = VirtualCodebase(
location=test_codebase,
codebase_attributes=dict(
packages=attr.ib(default=attr.Factory(list))
),
)
self.assertNotEqual(vc.attributes.packages, None)
self.assertEqual(vc.attributes.packages, [])


class TestCodebaseCache(FileBasedTesting):
test_data_dir = join(dirname(__file__), 'data')
Expand Down