Skip to content

Commit 38049df

Browse files
committed
refactor: format all code with Black
Black config was not changed but we have different result compared to main branch this is because Black determines supported Python versions from pyproject.toml in absence of the `requires-python` section it is determined on the per file basis now that we have full-fledged pyproject.toml Black follows our config more strictly
1 parent 1b105cb commit 38049df

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

test/test_extractor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,15 @@ async def test_extract_file_rpm(self, extension_list: list[str]):
163163
@pytest.mark.asyncio
164164
async def test_extract_file_rpm_no_rpm2cipo(self, extension_list: list[str]):
165165
"""Test rpm extraction using rpmfile"""
166-
with unittest.mock.patch(
167-
"cve_bin_tool.async_utils.aio_inpath",
168-
return_value=False,
169-
), unittest.mock.patch(
170-
"cve_bin_tool.async_utils.aio_run_command",
171-
) as mock_aio_run_command:
166+
with (
167+
unittest.mock.patch(
168+
"cve_bin_tool.async_utils.aio_inpath",
169+
return_value=False,
170+
),
171+
unittest.mock.patch(
172+
"cve_bin_tool.async_utils.aio_run_command",
173+
) as mock_aio_run_command,
174+
):
172175
await self.test_extract_file_rpm(extension_list)
173176
mock_aio_run_command.assert_not_called()
174177

test/test_output_engine.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,11 @@ def setUp(self) -> None:
964964

965965
def test_generate_sbom(self):
966966
"""Test SBOM generation"""
967-
with patch(
968-
"cve_bin_tool.sbom_manager.generate.SBOMPackage"
969-
) as mock_sbom_package, patch(
970-
"cve_bin_tool.sbom_manager.generate.SBOMRelationship"
967+
with (
968+
patch(
969+
"cve_bin_tool.sbom_manager.generate.SBOMPackage"
970+
) as mock_sbom_package,
971+
patch("cve_bin_tool.sbom_manager.generate.SBOMRelationship"),
971972
):
972973
mock_package_instance = MagicMock()
973974
mock_sbom_package.return_value = mock_package_instance
@@ -1030,10 +1031,11 @@ def test_generate_sbom(self):
10301031

10311032
def test_generate_sbom_no_scan_mode(self):
10321033
"""Test SBOM generation in no-scan mode"""
1033-
with patch(
1034-
"cve_bin_tool.sbom_manager.generate.SBOMPackage"
1035-
) as mock_sbom_package, patch(
1036-
"cve_bin_tool.sbom_manager.generate.SBOMRelationship"
1034+
with (
1035+
patch(
1036+
"cve_bin_tool.sbom_manager.generate.SBOMPackage"
1037+
) as mock_sbom_package,
1038+
patch("cve_bin_tool.sbom_manager.generate.SBOMRelationship"),
10371039
):
10381040
mock_package_instance = MagicMock()
10391041
mock_sbom_package.return_value = mock_package_instance

test/test_package_list_parser.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,10 @@ def test_parse_list_rpm_packages(
437437
mock_product_info.side_effect = [product_info1, product_info2]
438438

439439
# Setup Path mocks using context manager to avoid mocking Path.is_file globally
440-
with mock.patch("pathlib.Path.is_file", return_value=True), mock.patch(
441-
"pathlib.Path.stat"
442-
) as mock_stat:
440+
with (
441+
mock.patch("pathlib.Path.is_file", return_value=True),
442+
mock.patch("pathlib.Path.stat") as mock_stat,
443+
):
443444

444445
# Mock file stats
445446
mock_stat.return_value = mock.Mock(st_size=100)
@@ -470,15 +471,14 @@ def _check_file_deb(self):
470471
)
471472

472473
# Set up all the necessary mocks using context managers
473-
with mock.patch("distro.id", return_value="ubuntu"), mock.patch(
474-
"pathlib.Path.is_file", return_value=True
475-
), mock.patch("pathlib.Path.stat") as mock_stat, mock.patch(
476-
"subprocess.run"
477-
) as mock_run, mock.patch(
478-
"re.findall", return_value=["invalid-pkg1", "invalid-pkg2"]
479-
), mock.patch(
480-
"cve_bin_tool.package_list_parser.LOGGER"
481-
) as mock_logger:
474+
with (
475+
mock.patch("distro.id", return_value="ubuntu"),
476+
mock.patch("pathlib.Path.is_file", return_value=True),
477+
mock.patch("pathlib.Path.stat") as mock_stat,
478+
mock.patch("subprocess.run") as mock_run,
479+
mock.patch("re.findall", return_value=["invalid-pkg1", "invalid-pkg2"]),
480+
mock.patch("cve_bin_tool.package_list_parser.LOGGER") as mock_logger,
481+
):
482482

483483
# Mock stat result to return non-zero size
484484
mock_stat.return_value = mock.Mock(st_size=100)

0 commit comments

Comments
 (0)