Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not assign None to codebase attributes #48 #49

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Changes from 3 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
@@ -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 = [
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ license_files =
commoncode.ABOUT
README.rst
name = commoncode
version = 31.0.0
JonoYang marked this conversation as resolved.
Show resolved Hide resolved
author = nexB. Inc. and others
author_email = info@aboutcode.org
license = Apache-2.0
2 changes: 2 additions & 0 deletions src/commoncode/resource.py
Original file line number Diff line number Diff line change
@@ -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)

##########################################################
13 changes: 13 additions & 0 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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')