fix: honor repo bandit config in badge quality check
CI / validate (pull_request) Failing after 1m16s
CI / auto-merge (pull_request) Skipped

This commit is contained in:
Emil Simeonov
2026-09-21 20:44:14 +02:00
parent 3b2a278f87
commit 1a42216b02
3 changed files with 65 additions and 1 deletions
+17
View File
@@ -365,6 +365,23 @@ class TestCollectQuality:
badge = collect_quality(tmp_path)
assert badge["message"] == "A"
@patch("devx.tools.generate_badges.run_command")
def test_bandit_uses_repo_config_when_present(self, mock_run: MagicMock, tmp_path: Path) -> None: # type: ignore[no-untyped-def]
(tmp_path / "pyproject.toml").write_text("[tool.bandit]\nskips = ['B501']\n")
mock_run.return_value = (0, "", "")
collect_quality(tmp_path)
bandit_call = [c for c in mock_run.call_args_list if "bandit" in c.args[0]][0]
assert "-c" in bandit_call.args[0]
assert "pyproject.toml" in bandit_call.args[0]
@patch("devx.tools.generate_badges.run_command")
def test_bandit_plain_invocation_without_repo_config(self, mock_run: MagicMock, tmp_path: Path) -> None: # type: ignore[no-untyped-def]
(tmp_path / "pyproject.toml").write_text("[project]\nname = 'x'\n")
mock_run.return_value = (0, "", "")
collect_quality(tmp_path)
bandit_call = [c for c in mock_run.call_args_list if "bandit" in c.args[0]][0]
assert "-c" not in bandit_call.args[0]
class TestGenerateBadges:
@patch("devx.tools.generate_badges.collect_quality")