diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d56fe6c..fb62dbe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: - prettier-plugin-sort-json - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black @@ -59,14 +59,14 @@ repos: - id: tox-ini-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.9 + rev: v0.7.2 hooks: - id: ruff args: - --exit-non-zero-on-fix - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v8.13.3 + rev: v8.15.2 hooks: - id: cspell name: Spell check with cspell @@ -94,7 +94,7 @@ repos: - setuptools - repo: https://github.com/pre-commit/mirrors-mypy.git - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy additional_dependencies: diff --git a/src/pytest_ansible/fixtures.py b/src/pytest_ansible/fixtures.py index f6847a2..3d7f4e0 100644 --- a/src/pytest_ansible/fixtures.py +++ b/src/pytest_ansible/fixtures.py @@ -23,13 +23,13 @@ def fixture_ansible_module(ansible_adhoc): # type: ignore[no-untyped-def] # no return getattr(host_mgr, host_mgr.options["host_pattern"]) -@pytest.fixture() +@pytest.fixture def ansible_facts(ansible_module): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """Return ansible_facts dictionary.""" return ansible_module.setup() -@pytest.fixture() +@pytest.fixture def localhost(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """Return a host manager representing localhost.""" # NOTE: Do not use ansible_adhoc as a dependent fixture since that will assert specific command-line parameters have # noqa: E501 diff --git a/tests/conftest.py b/tests/conftest.py index 8d476b8..4b76707 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -156,7 +156,7 @@ def _clear_global_context(): # type: ignore[no-untyped-def] # noqa: ANN202 co.GlobalCLIArgs._Singleton__instance = None -@pytest.fixture() +@pytest.fixture def option(request, pytester): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """Returns an instance of PyTestOption to help tests pass parameters and use a common inventory file. @@ -164,7 +164,7 @@ def option(request, pytester): # type: ignore[no-untyped-def] # noqa: ANN001, return PyTestOption(request.config, pytester) -@pytest.fixture() +@pytest.fixture def hosts(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 def create_host_manager(include_extra_inventory=False): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202, FBT002 kwargs = {"inventory": ",".join(ALL_HOSTS), "connection": "local"} diff --git a/tests/test_adhoc.py b/tests/test_adhoc.py index eaa851f..d899a33 100644 --- a/tests/test_adhoc.py +++ b/tests/test_adhoc.py @@ -24,7 +24,7 @@ EXIT_NOTESTSCOLLECTED = ExitCode.NO_TESTS_COLLECTED -@pytest.mark.old() +@pytest.mark.old def test_contacted_with_params(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = """ @@ -54,7 +54,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_contacted_with_params_and_inventory_marker(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = f""" @@ -80,7 +80,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_contacted_with_params_and_host_pattern_marker(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = """ @@ -111,7 +111,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_contacted_with_params_and_inventory_host_pattern_marker(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = f""" @@ -142,7 +142,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_become(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """Test --ansible-become* parameters. This test doesn't actually 'sudo', but verifies that 'sudo' was attempted by asserting @@ -194,7 +194,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_dark_with_params(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = """ @@ -224,7 +224,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_dark_with_params_and_inventory_marker(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = f""" @@ -250,7 +250,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_dark_with_params_and_host_pattern_marker(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """FIXME.""" src = """ @@ -282,7 +282,7 @@ def test_func(ansible_module): assert result.parseoutcomes()["passed"] == 1 -@pytest.mark.old() +@pytest.mark.old def test_dark_with_debug_enabled(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 """Verify that when verbosity is enabled, additional output is provided upon host failure.""" src = """ diff --git a/tests/test_adhoc_result.py b/tests/test_adhoc_result.py index 3cd4dec..543bc42 100644 --- a/tests/test_adhoc_result.py +++ b/tests/test_adhoc_result.py @@ -117,7 +117,7 @@ def test_not_getattr(adhoc_result, host_pattern): # type: ignore[no-untyped-def getattr(adhoc_result_ret, host_pattern) -@pytest.mark.requires_ansible_v2() +@pytest.mark.requires_ansible_v2 def test_connection_failure_v2(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 from pytest_ansible.errors import AnsibleConnectionFailure from pytest_ansible.host_manager.utils import get_host_manager @@ -141,7 +141,7 @@ def test_connection_failure_v2(): # type: ignore[no-untyped-def] # noqa: ANN20 ) -@pytest.mark.requires_ansible_v2() +@pytest.mark.requires_ansible_v2 def test_connection_failure_extra_inventory_v2(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 from pytest_ansible.errors import AnsibleConnectionFailure from pytest_ansible.host_manager.utils import get_host_manager diff --git a/tests/test_module_dispatcher.py b/tests/test_module_dispatcher.py index dff0b01..9f5b25f 100644 --- a/tests/test_module_dispatcher.py +++ b/tests/test_module_dispatcher.py @@ -15,7 +15,7 @@ def test_type_error() -> None: BaseModuleDispatcher(inventory="localhost,") # type: ignore[abstract] #pylint: disable=abstract-class-instantiated -@pytest.mark.requires_ansible_v2() +@pytest.mark.requires_ansible_v2 def test_importerror_requires_v1(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 with pytest.raises(ImportError): # pylint: disable=unused-import diff --git a/tests/test_module_result.py b/tests/test_module_result.py index a13b2ea..9449d1c 100644 --- a/tests/test_module_result.py +++ b/tests/test_module_result.py @@ -28,7 +28,7 @@ invalid_hosts = ("none", "all", "*", "local*") -@pytest.fixture() +@pytest.fixture def module_result_ok(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, ARG001, D103 return ModuleResult( invocation={"module_name": "debug", "module_args": {"msg": "testing"}}, @@ -39,7 +39,7 @@ def module_result_ok(request): # type: ignore[no-untyped-def] # noqa: ANN001, ) -@pytest.fixture() +@pytest.fixture def module_result_failed(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 return ModuleResult( invocation={"module_name": "fail", "module_args": {}}, @@ -50,7 +50,7 @@ def module_result_failed(): # type: ignore[no-untyped-def] # noqa: ANN201, D10 ) -@pytest.fixture() +@pytest.fixture def module_result_changed(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, ARG001, D103 return ModuleResult( changed=True, @@ -79,13 +79,13 @@ def module_result_changed(request): # type: ignore[no-untyped-def] # noqa: ANN ) -@pytest.fixture() +@pytest.fixture def _module_result_skipped(): # type: ignore[no-untyped-def] # noqa: ANN202 msg = "Coming soon!" raise NotImplementedError(msg) -@pytest.fixture() +@pytest.fixture def _module_result_unreachable(): # type: ignore[no-untyped-def] # noqa: ANN202 msg = "Coming soon!" raise NotImplementedError(msg) diff --git a/tests/test_params.py b/tests/test_params.py index f975913..3b619d9 100644 --- a/tests/test_params.py +++ b/tests/test_params.py @@ -149,7 +149,7 @@ def test_func(ansible_module): ) -@pytest.mark.requires_ansible_v2() +@pytest.mark.requires_ansible_v2 def test_params_required_without_inventory_with_host_pattern_v2(pytester, option): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 src = """ import pytest