diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d3693f0dc..97e1b2267 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,9 +7,14 @@ updates: schedule: interval: "weekly" day: "monday" - open-pull-requests-limit: 4 cooldown: default-days: 7 + open-pull-requests-limit: 1 + groups: + all-github-actions: + applies-to: version-updates + patterns: + - "*" # Maintain dependencies for poetry - package-ecosystem: "pip" diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 4a9a30f57..10208a068 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/.github/workflows/check-release-tag.yml b/.github/workflows/check-release-tag.yml index a6297b4c7..079aa44a2 100644 --- a/.github/workflows/check-release-tag.yml +++ b/.github/workflows/check-release-tag.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index dcdb0dca1..8e5f07ec3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" @@ -47,7 +47,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" @@ -74,7 +74,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: ${{ matrix.python-versions }} poetry-version: "2.3.0" @@ -112,7 +112,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: ${{ matrix.python-versions }} poetry-version: "2.3.0" @@ -140,7 +140,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: ${{ matrix.python-versions }} poetry-version: "2.3.0" @@ -172,7 +172,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" @@ -195,7 +195,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" @@ -218,7 +218,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" @@ -241,7 +241,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/.github/workflows/dependency-update.yml b/.github/workflows/dependency-update.yml index 1d443bb30..c61af68c5 100644 --- a/.github/workflows/dependency-update.yml +++ b/.github/workflows/dependency-update.yml @@ -34,7 +34,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/.github/workflows/fast-tests.yml b/.github/workflows/fast-tests.yml index a5999cf36..227e5e522 100644 --- a/.github/workflows/fast-tests.yml +++ b/.github/workflows/fast-tests.yml @@ -24,7 +24,7 @@ jobs: fetch-depth: 0 - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: ${{ matrix.python-versions }} poetry-version: "2.3.0" diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index ff7cf6298..7972a6644 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml index 374ec311f..fc8933b40 100644 --- a/.github/workflows/matrix.yml +++ b/.github/workflows/matrix.yml @@ -27,7 +27,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/.github/workflows/report.yml b/.github/workflows/report.yml index c7fd8d5c5..1edb2268a 100644 --- a/.github/workflows/report.yml +++ b/.github/workflows/report.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Python & Poetry Environment id: set-up-python-and-poetry-environment - uses: exasol/python-toolbox/.github/actions/python-environment@v12 + uses: exasol/python-toolbox/.github/actions/python-environment@v13 with: python-version: "3.11" poetry-version: "2.3.0" diff --git a/doc/changes/unreleased.md b/doc/changes/unreleased.md index fb4737052..61e89e88e 100644 --- a/doc/changes/unreleased.md +++ b/doc/changes/unreleased.md @@ -1,3 +1,7 @@ # Unreleased ## Summary + +## Refactoring + +* #1009: Fixed Sonar issues in test files diff --git a/test/unit/nox/_package_check_test.py b/test/unit/nox/_package_check_test.py index 571e12874..d17e7383b 100644 --- a/test/unit/nox/_package_check_test.py +++ b/test/unit/nox/_package_check_test.py @@ -42,11 +42,11 @@ def test_raises_non_zero_exist_with_readme_error( package_readme.open(mode="a").write(not_closed_link_error) # use of the folder with errors in the nox -s package:check function - with pytest.raises(CommandFailed) as e: - with patch( - "exasol.toolbox.nox._package.PROJECT_CONFIG", - new=test_project_config_factory(), - ): + with patch( + "exasol.toolbox.nox._package.PROJECT_CONFIG", + new=test_project_config_factory(), + ): + with pytest.raises(CommandFailed) as e: package_check(nox_session) # verify broken with non-zero exit status assert str(e.value) == "Returned code 1" diff --git a/test/unit/nox/conftest.py b/test/unit/nox/conftest.py index 90862e3c7..6ad79bbba 100644 --- a/test/unit/nox/conftest.py +++ b/test/unit/nox/conftest.py @@ -53,4 +53,4 @@ def nox_session_runner(tmp_path, nox_session_runner_posargs): def nox_session(nox_session_runner): # Extracted from nox testing nox_session_runner.venv = make_fake_env(bin_paths=["/no/bin/for/you"]) - yield Session(nox_session_runner) + return Session(nox_session_runner) diff --git a/test/unit/security_test.py b/test/unit/security_test.py index 60052de5a..c9ae49aa5 100644 --- a/test/unit/security_test.py +++ b/test/unit/security_test.py @@ -224,7 +224,7 @@ def test_with_filled_input(sample_maven_vulnerabilities): @staticmethod def test_with_empty_input(): actual = set(security.from_maven("{}")) - assert len(actual) == 0 + assert actual == set() def test_format_jsonl(): diff --git a/test/unit/util/dependencies/shared_models_test.py b/test/unit/util/dependencies/shared_models_test.py index 3d085ffad..accedbc00 100644 --- a/test/unit/util/dependencies/shared_models_test.py +++ b/test/unit/util/dependencies/shared_models_test.py @@ -75,13 +75,11 @@ def test_works_as_expected(): @staticmethod def test_raises_exception_when_latest_tag_not_found(): - with pytest.raises(LatestTagNotFoundError): - with mock.patch.object( - Git, - "get_latest_tag", - side_effect=CalledProcessError( - cmd="Mocked subprocess error", returncode=1 - ), - ): + with mock.patch.object( + Git, + "get_latest_tag", + side_effect=CalledProcessError(cmd="Mocked subprocess error", returncode=1), + ): + with pytest.raises(LatestTagNotFoundError): with poetry_files_from_latest_tag(root_path=PROJECT_CONFIG.root_path): pass diff --git a/test/unit/util/release/changelog_test.py b/test/unit/util/release/changelog_test.py index 42d5f3bbe..2e9efd360 100644 --- a/test/unit/util/release/changelog_test.py +++ b/test/unit/util/release/changelog_test.py @@ -111,7 +111,7 @@ def expected_changes( return changes -@pytest.fixture(scope="function") +@pytest.fixture def changelog(tmp_path) -> Changelog: changes_path = tmp_path / "doc/changes" changes_path.mkdir(parents=True) @@ -122,17 +122,17 @@ def changelog(tmp_path) -> Changelog: ) -@pytest.fixture(scope="function") +@pytest.fixture def changelog_md(changelog): changelog.changelog.write_text(SampleContent.old_changelog) -@pytest.fixture(scope="function") +@pytest.fixture def unreleased_md(changelog): changelog.unreleased.write_text(SampleContent.unreleased) -@pytest.fixture(scope="function") +@pytest.fixture def unreleased_with_security_issues(changelog) -> str: security = _markdown(""" ## Security Issues @@ -147,7 +147,7 @@ def unreleased_with_security_issues(changelog) -> str: VulnerabilityChanges = tuple[Mock | dict, Mock | dict] | None -@pytest.fixture(scope="function") +@pytest.fixture def dependency_changes(previous_dependencies, dependencies) -> DependencyChanges: return (previous_dependencies, dependencies) @@ -179,17 +179,17 @@ def mock( return mock -@pytest.fixture(scope="function") +@pytest.fixture def mock_no_dependencies(mock_changelog): mock_changelog() -@pytest.fixture(scope="function") +@pytest.fixture def mock_dependencies(mock_changelog, dependency_changes): mock_changelog(dependencies=dependency_changes) -@pytest.fixture(scope="function") +@pytest.fixture def vulnerability_changes(sample_vulnerability) -> VulnerabilityChanges: """ Simulate resolved vulnerabilities. @@ -200,19 +200,19 @@ def vulnerability_changes(sample_vulnerability) -> VulnerabilityChanges: return (previous, current) -@pytest.fixture(scope="function") +@pytest.fixture def mock_vulnerabilties(mock_changelog, vulnerability_changes): mock_changelog(vulnerabilities=vulnerability_changes) -@pytest.fixture(scope="function") +@pytest.fixture def mock_dependencies_and_vulnerabilties( mock_changelog, dependency_changes, vulnerability_changes ): mock_changelog(dependency_changes, vulnerability_changes) -@pytest.fixture(scope="function") +@pytest.fixture def mock_new_dependencies(mock_changelog, dependencies): mock_changelog( dependencies=(Mock(side_effect=LatestTagNotFoundError), dependencies) diff --git a/test/unit/util/version_test.py b/test/unit/util/version_test.py index 1d666c5bb..b6d4ec30e 100644 --- a/test/unit/util/version_test.py +++ b/test/unit/util/version_test.py @@ -51,7 +51,7 @@ def set_poetry_version(version): stderr="", ) - yield set_poetry_version + return set_poetry_version @pytest.mark.parametrize(