diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 006e2bbc0..c51d70105 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 diff --git a/tests/conftest.py b/tests/conftest.py index 50c602658..f4e17f75a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -81,7 +81,7 @@ def _no_color(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.delitem(os.environ, "FORCE_COLOR", raising=False) -@pytest.fixture() +@pytest.fixture def resources_folder_path() -> Path: """Return the path to the resources folder. @@ -127,7 +127,7 @@ def reset_pytest_vars(monkeypatch): # type: ignore[no-untyped-def] # noqa: ANN monkeypatch.delenv(var_name, raising=False) -@pytest.fixture() +@pytest.fixture def test_fixture_dir(request: pytest.FixtureRequest) -> Path: """Provide the fixture directory for a given test. diff --git a/tests/integration/test_command.py b/tests/integration/test_command.py index 638ce2bbb..235c1e6c3 100644 --- a/tests/integration/test_command.py +++ b/tests/integration/test_command.py @@ -73,7 +73,7 @@ class ParamDefault(TypedDict): } -@pytest.mark.extensive() +@pytest.mark.extensive @pytest.mark.parametrize(**PARAMS_DEFAULT) @pytest.mark.usefixtures("with_scenario") @pytest.mark.parametrize( @@ -112,7 +112,7 @@ def test_command( assert "PLAY RECAP" in result.stdout -@pytest.mark.extensive() +@pytest.mark.extensive @pytest.mark.parametrize(**PARAMS_DEFAULT) @pytest.mark.usefixtures("with_scenario") def test_command_idempotence(test_ephemeral_dir_env: dict[str, str], scenario_name: str) -> None: @@ -200,7 +200,7 @@ def test_command_list_with_format_plain( assert result.stdout == "instance default ansible default false false\n" -@pytest.mark.extensive() +@pytest.mark.extensive @pytest.mark.parametrize(**PARAMS_DEFAULT) @pytest.mark.usefixtures("with_scenario") @pytest.mark.parametrize(("platform", "missing"), (("instance", False), ("gonzo", True))) diff --git a/tests/unit/command/conftest.py b/tests/unit/command/conftest.py index 8ea4c686a..571dbf78a 100644 --- a/tests/unit/command/conftest.py +++ b/tests/unit/command/conftest.py @@ -22,12 +22,12 @@ import pytest -@pytest.fixture() +@pytest.fixture def command_patched_ansible_create(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("molecule.provisioner.ansible.Ansible.create") -@pytest.fixture() +@pytest.fixture def command_driver_delegated_section_data(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 x = { "driver": { @@ -42,6 +42,6 @@ def command_driver_delegated_section_data(): # type: ignore[no-untyped-def] # return x # noqa: RET504 -@pytest.fixture() +@pytest.fixture def command_driver_delegated_managed_section_data(): # type: ignore[no-untyped-def] # noqa: ANN201, D103 return {"driver": {"name": "default", "managed": True}} diff --git a/tests/unit/command/test_check.py b/tests/unit/command/test_check.py index e5ab15f20..5e2b9c0f7 100644 --- a/tests/unit/command/test_check.py +++ b/tests/unit/command/test_check.py @@ -34,7 +34,7 @@ from molecule import config -@pytest.fixture() +@pytest.fixture def _patched_ansible_check(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.provisioner.ansible.Ansible.check") diff --git a/tests/unit/command/test_cleanup.py b/tests/unit/command/test_cleanup.py index 031bbd5ad..c710ccaa0 100644 --- a/tests/unit/command/test_cleanup.py +++ b/tests/unit/command/test_cleanup.py @@ -38,14 +38,14 @@ from molecule.types import ProvisionerData -@pytest.fixture() +@pytest.fixture def _command_provisioner_section_with_cleanup_data() -> ( dict[Literal["provisioner"], ProvisionerData] ): return {"provisioner": {"name": "ansible", "playbooks": {"cleanup": "cleanup.yml"}}} -@pytest.fixture() +@pytest.fixture def _patched_ansible_cleanup(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.provisioner.ansible.Ansible.cleanup") diff --git a/tests/unit/command/test_create.py b/tests/unit/command/test_create.py index 56f1539c0..23e3d1796 100644 --- a/tests/unit/command/test_create.py +++ b/tests/unit/command/test_create.py @@ -34,7 +34,7 @@ from molecule import config -@pytest.fixture() +@pytest.fixture def _patched_create_setup(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.command.create.Create._setup") diff --git a/tests/unit/command/test_destroy.py b/tests/unit/command/test_destroy.py index 5fca7d778..ee5d71fef 100644 --- a/tests/unit/command/test_destroy.py +++ b/tests/unit/command/test_destroy.py @@ -34,12 +34,12 @@ from molecule import config -@pytest.fixture() +@pytest.fixture def _patched_ansible_destroy(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.provisioner.ansible.Ansible.destroy") -@pytest.fixture() +@pytest.fixture def _patched_destroy_setup(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.command.destroy.Destroy._setup") diff --git a/tests/unit/command/test_idempotence.py b/tests/unit/command/test_idempotence.py index 6a5a94744..649400bb4 100644 --- a/tests/unit/command/test_idempotence.py +++ b/tests/unit/command/test_idempotence.py @@ -34,7 +34,7 @@ from molecule import config -@pytest.fixture() +@pytest.fixture def _patched_is_idempotent(mocker: MockerFixture) -> Mock: return mocker.patch("molecule.command.idempotence.Idempotence._is_idempotent") @@ -42,7 +42,7 @@ def _patched_is_idempotent(mocker: MockerFixture) -> Mock: # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance(patched_config_validate, config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202, ARG001 config_instance.state.change_state("converged", True) # noqa: FBT003 diff --git a/tests/unit/command/test_login.py b/tests/unit/command/test_login.py index 9b97ee9cd..41eb93f0b 100644 --- a/tests/unit/command/test_login.py +++ b/tests/unit/command/test_login.py @@ -32,7 +32,7 @@ from molecule import config -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config) -> login.Login: config_instance.state.change_state("created", value=True) diff --git a/tests/unit/command/test_prepare.py b/tests/unit/command/test_prepare.py index b7b23dbbe..d6b789863 100644 --- a/tests/unit/command/test_prepare.py +++ b/tests/unit/command/test_prepare.py @@ -35,7 +35,7 @@ from pytest_mock import MockerFixture -@pytest.fixture() +@pytest.fixture def _patched_ansible_prepare(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.provisioner.ansible.Ansible.prepare") diff --git a/tests/unit/command/test_side_effect.py b/tests/unit/command/test_side_effect.py index 8724d7ecc..4faaa6526 100644 --- a/tests/unit/command/test_side_effect.py +++ b/tests/unit/command/test_side_effect.py @@ -38,7 +38,7 @@ from molecule.types import ProvisionerData -@pytest.fixture() +@pytest.fixture def _command_provisioner_section_with_side_effect_data() -> ( dict[Literal["provisioner"], ProvisionerData] ): @@ -50,7 +50,7 @@ def _command_provisioner_section_with_side_effect_data() -> ( } -@pytest.fixture() +@pytest.fixture def _patched_ansible_side_effect(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.provisioner.ansible.Ansible.side_effect") diff --git a/tests/unit/command/test_syntax.py b/tests/unit/command/test_syntax.py index 0ec21629e..a2fd702bf 100644 --- a/tests/unit/command/test_syntax.py +++ b/tests/unit/command/test_syntax.py @@ -34,7 +34,7 @@ from molecule import config -@pytest.fixture() +@pytest.fixture def _patched_ansible_syntax(mocker: MockerFixture) -> MagicMock: return mocker.patch("molecule.provisioner.ansible.Ansible.syntax") diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 17086181d..638711129 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -69,7 +69,7 @@ def fixture_molecule_data() -> dict[str, Any]: } -@pytest.fixture() +@pytest.fixture def config_instance( monkeypatch: pytest.MonkeyPatch, molecule_data: dict[str, Any], @@ -121,27 +121,27 @@ def _filter_ignored_scenarios(scenario_paths: list[str]) -> list[str]: # Mocks -@pytest.fixture() +@pytest.fixture def patched_print_debug(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("molecule.util.print_debug") -@pytest.fixture() +@pytest.fixture def patched_logger_info(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("logging.Logger.info") -@pytest.fixture() +@pytest.fixture def patched_logger_debug(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("logging.Logger.debug") -@pytest.fixture() +@pytest.fixture def patched_logger_error(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("logging.Logger.error") -@pytest.fixture() +@pytest.fixture def patched_run_command(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 m = mocker.patch("molecule.util.run_command") m.return_value = CompletedProcess( @@ -154,7 +154,7 @@ def patched_run_command(mocker): # type: ignore[no-untyped-def] # noqa: ANN001 return m -@pytest.fixture() +@pytest.fixture def patched_ansible_converge(mocker: MockerFixture) -> Mock: # noqa: D103 m = mocker.patch("molecule.provisioner.ansible.Ansible.converge") m.return_value = "patched-ansible-converge-stdout" @@ -162,28 +162,28 @@ def patched_ansible_converge(mocker: MockerFixture) -> Mock: # noqa: D103 return m -@pytest.fixture() +@pytest.fixture def patched_add_or_update_vars(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("molecule.provisioner.ansible.Ansible._add_or_update_vars") -@pytest.fixture() +@pytest.fixture def patched_ansible_galaxy(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("molecule.dependency.ansible_galaxy.AnsibleGalaxy.execute") -@pytest.fixture() +@pytest.fixture def patched_default_verifier(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("molecule.verifier.ansible.Ansible.execute") -@pytest.fixture() +@pytest.fixture def patched_scenario_setup(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 mocker.patch("molecule.config.Config.env") return mocker.patch("molecule.scenario.Scenario._setup") -@pytest.fixture() +@pytest.fixture def patched_config_validate(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return mocker.patch("molecule.config.Config._validate") diff --git a/tests/unit/dependency/ansible_galaxy/test_collections.py b/tests/unit/dependency/ansible_galaxy/test_collections.py index 282a6ec08..2eb916337 100644 --- a/tests/unit/dependency/ansible_galaxy/test_collections.py +++ b/tests/unit/dependency/ansible_galaxy/test_collections.py @@ -27,7 +27,7 @@ from molecule.dependency.ansible_galaxy import collections -@pytest.fixture() +@pytest.fixture def _patched_ansible_galaxy_has_requirements_file(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 m = mocker.patch( "molecule.dependency.ansible_galaxy.collections.Collections._has_requirements_file", @@ -37,7 +37,7 @@ def _patched_ansible_galaxy_has_requirements_file(mocker): # type: ignore[no-un return m -@pytest.fixture() +@pytest.fixture def _dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "dependency": { @@ -51,7 +51,7 @@ def _dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance( # type: ignore[no-untyped-def] # noqa: ANN202 _dependency_section_data, # noqa: ANN001 patched_config_validate, # noqa: ANN001, ARG001 diff --git a/tests/unit/dependency/ansible_galaxy/test_roles.py b/tests/unit/dependency/ansible_galaxy/test_roles.py index f902b1289..8070771e1 100644 --- a/tests/unit/dependency/ansible_galaxy/test_roles.py +++ b/tests/unit/dependency/ansible_galaxy/test_roles.py @@ -27,7 +27,7 @@ from molecule.dependency.ansible_galaxy import roles -@pytest.fixture() +@pytest.fixture def _patched_ansible_galaxy_has_requirements_file(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 m = mocker.patch( "molecule.dependency.ansible_galaxy.roles.Roles._has_requirements_file", @@ -37,7 +37,7 @@ def _patched_ansible_galaxy_has_requirements_file(mocker): # type: ignore[no-un return m -@pytest.fixture() +@pytest.fixture def _dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "dependency": { @@ -51,7 +51,7 @@ def _dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance( # type: ignore[no-untyped-def] # noqa: ANN202 _dependency_section_data, # noqa: ANN001 patched_config_validate, # noqa: ANN001, ARG001 diff --git a/tests/unit/dependency/test_shell.py b/tests/unit/dependency/test_shell.py index 76fd53763..67457cd59 100644 --- a/tests/unit/dependency/test_shell.py +++ b/tests/unit/dependency/test_shell.py @@ -25,7 +25,7 @@ from molecule.dependency import shell -@pytest.fixture() +@pytest.fixture def _dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "dependency": { @@ -40,7 +40,7 @@ def _dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance( # type: ignore[no-untyped-def] # noqa: ANN202 _dependency_section_data, # noqa: ANN001 patched_config_validate, # noqa: ANN001, ARG001 diff --git a/tests/unit/driver/test_delegated.py b/tests/unit/driver/test_delegated.py index d074c738c..cd201a7da 100644 --- a/tests/unit/driver/test_delegated.py +++ b/tests/unit/driver/test_delegated.py @@ -34,7 +34,7 @@ from pytest_mock import MockerFixture -@pytest.fixture() +@pytest.fixture def _driver_managed_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "driver": { @@ -46,7 +46,7 @@ def _driver_managed_section_data(): # type: ignore[no-untyped-def] # noqa: ANN } -@pytest.fixture() +@pytest.fixture def _driver_unmanaged_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "driver": { @@ -58,7 +58,7 @@ def _driver_unmanaged_section_data(): # type: ignore[no-untyped-def] # noqa: A } -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN202 return delegated.Delegated(config_instance) @@ -340,7 +340,7 @@ def test_delegated_created(_instance): # type: ignore[no-untyped-def] # noqa: assert _instance._created() == "false" -@pytest.fixture() +@pytest.fixture def _driver_options_managed_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"options": {"managed": False}}} diff --git a/tests/unit/model/v2/conftest.py b/tests/unit/model/v2/conftest.py index 2665e8797..15bd797ab 100644 --- a/tests/unit/model/v2/conftest.py +++ b/tests/unit/model/v2/conftest.py @@ -45,7 +45,7 @@ def fixture_molecule_file(resources_folder_path: Path) -> Path: return resources_folder_path / "molecule.yml" -@pytest.fixture() +@pytest.fixture def config(molecule_file: Path, request: pytest.FixtureRequest) -> dict[str, Any]: """Return merged molecule file data. @@ -68,7 +68,7 @@ def config(molecule_file: Path, request: pytest.FixtureRequest) -> dict[str, Any return d # type: ignore[no-any-return] -@pytest.fixture() +@pytest.fixture def _model_platforms_delegated_section_data() -> str: return """ --- diff --git a/tests/unit/model/v2/test_dependency_section.py b/tests/unit/model/v2/test_dependency_section.py index 35b41dc76..76f38850e 100644 --- a/tests/unit/model/v2/test_dependency_section.py +++ b/tests/unit/model/v2/test_dependency_section.py @@ -24,7 +24,7 @@ from molecule.model import schema_v3 -@pytest.fixture() +@pytest.fixture def _model_dependency_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "dependency": { @@ -45,7 +45,7 @@ def test_dependency(config): # type: ignore[no-untyped-def] # noqa: ANN001, AN assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_dependency_errors_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"dependency": {"name": 0}} @@ -61,12 +61,12 @@ def test_dependency_has_errors(config): # type: ignore[no-untyped-def] # noqa: assert x == schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_dependency_allows_galaxy_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"dependency": {"name": "galaxy"}} -@pytest.fixture() +@pytest.fixture def _model_dependency_allows_shell_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"dependency": {"name": "shell"}} @@ -83,7 +83,7 @@ def test_dependency_allows_shell_name(config): # type: ignore[no-untyped-def] assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_dependency_shell_errors_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"dependency": {"name": "shell", "command": None}} diff --git a/tests/unit/model/v2/test_driver_section.py b/tests/unit/model/v2/test_driver_section.py index 46e00c99f..56bcc92f4 100644 --- a/tests/unit/model/v2/test_driver_section.py +++ b/tests/unit/model/v2/test_driver_section.py @@ -24,7 +24,7 @@ from molecule.model import schema_v3 -@pytest.fixture() +@pytest.fixture def _model_driver_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "driver": { @@ -42,7 +42,7 @@ def test_driver(config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201 assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_driver_errors_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "driver": { @@ -51,7 +51,7 @@ def _model_driver_errors_section_data(): # type: ignore[no-untyped-def] # noqa } -@pytest.fixture() +@pytest.fixture def _model_driver_errors_section_data_no_prefix(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "driver": { @@ -80,7 +80,7 @@ def test_driver_has_errors(config): # type: ignore[no-untyped-def] # noqa: ANN assert error_msg == schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_driver_provider_name_nullable_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"provider": {"name": None}}} @@ -94,27 +94,27 @@ def test_driver_provider_name_nullable(config): # type: ignore[no-untyped-def] assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_driver_allows_delegated_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"name": "default"}} -@pytest.fixture() +@pytest.fixture def _model_driver_allows_molecule_section_data1(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"name": "molecule-test_driver.name"}} -@pytest.fixture() +@pytest.fixture def _model_driver_allows_molecule_section_data2(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"name": "molecule_test_driver.name"}} -@pytest.fixture() +@pytest.fixture def _model_driver_allows_custom_section_data1(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"name": "custom-test_driver.name"}} -@pytest.fixture() +@pytest.fixture def _model_driver_allows_custom_section_data2(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"driver": {"name": "custom_test_driver.name"}} diff --git a/tests/unit/model/v2/test_provisioner_section.py b/tests/unit/model/v2/test_provisioner_section.py index a60a874e8..b37f7a824 100644 --- a/tests/unit/model/v2/test_provisioner_section.py +++ b/tests/unit/model/v2/test_provisioner_section.py @@ -24,7 +24,7 @@ from molecule.model import schema_v3 -@pytest.fixture() +@pytest.fixture def _model_provisioner_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "provisioner": { @@ -62,7 +62,7 @@ def test_provisioner(config): # type: ignore[no-untyped-def] # noqa: ANN001, A assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_provisioner_errors_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "provisioner": { @@ -82,7 +82,7 @@ def test_provisioner_has_errors(config): # type: ignore[no-untyped-def] # noqa assert x == schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_provisioner_allows_ansible_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"provisioner": {"name": "ansible"}} diff --git a/tests/unit/model/v2/test_scenario_section.py b/tests/unit/model/v2/test_scenario_section.py index 6e3ed8afb..63ce2ed8b 100644 --- a/tests/unit/model/v2/test_scenario_section.py +++ b/tests/unit/model/v2/test_scenario_section.py @@ -24,7 +24,7 @@ from molecule.model import schema_v3 -@pytest.fixture() +@pytest.fixture def _model_scenario_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "scenario": { @@ -43,7 +43,7 @@ def test_scenario(config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN2 assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_scenario_errors_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"scenario": {"name": 0}} diff --git a/tests/unit/model/v2/test_verifier_section.py b/tests/unit/model/v2/test_verifier_section.py index b4015bc74..aee5e7048 100644 --- a/tests/unit/model/v2/test_verifier_section.py +++ b/tests/unit/model/v2/test_verifier_section.py @@ -24,7 +24,7 @@ from molecule.model import schema_v3 -@pytest.fixture() +@pytest.fixture def _model_verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "verifier": { @@ -43,7 +43,7 @@ def test_verifier(config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN2 assert not schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_verifier_errors_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "verifier": { @@ -63,12 +63,12 @@ def test_verifier_has_errors(config): # type: ignore[no-untyped-def] # noqa: A assert x == schema_v3.validate(config) # type: ignore[no-untyped-call] -@pytest.fixture() +@pytest.fixture def _model_verifier_allows_testinfra_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"verifier": {"name": "testinfra"}} -@pytest.fixture() +@pytest.fixture def _model_verifier_allows_ansible_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"verifier": {"name": "ansible"}} diff --git a/tests/unit/provisioner/test_ansible.py b/tests/unit/provisioner/test_ansible.py index 1868372bc..37aa14c64 100644 --- a/tests/unit/provisioner/test_ansible.py +++ b/tests/unit/provisioner/test_ansible.py @@ -37,7 +37,7 @@ from pytest_mock import MockerFixture -@pytest.fixture() +@pytest.fixture def _patched_ansible_playbook(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 m = mocker.patch("molecule.provisioner.ansible_playbook.AnsiblePlaybook") m.return_value.execute.return_value = b"patched-ansible-playbook-stdout" @@ -45,22 +45,22 @@ def _patched_ansible_playbook(mocker): # type: ignore[no-untyped-def] # noqa: return m -@pytest.fixture() +@pytest.fixture def _patched_write_inventory(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 return mocker.patch("molecule.provisioner.ansible.Ansible._write_inventory") -@pytest.fixture() +@pytest.fixture def _patched_remove_vars(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 return mocker.patch("molecule.provisioner.ansible.Ansible._remove_vars") -@pytest.fixture() +@pytest.fixture def _patched_link_or_update_vars(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 return mocker.patch("molecule.provisioner.ansible.Ansible._link_or_update_vars") -@pytest.fixture() +@pytest.fixture def _provisioner_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "provisioner": { diff --git a/tests/unit/provisioner/test_ansible_playbook.py b/tests/unit/provisioner/test_ansible_playbook.py index 427d239f9..0b773dd5c 100644 --- a/tests/unit/provisioner/test_ansible_playbook.py +++ b/tests/unit/provisioner/test_ansible_playbook.py @@ -27,24 +27,24 @@ from molecule.provisioner import ansible_playbook -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN202 _instance = ansible_playbook.AnsiblePlaybook("playbook", config_instance) return _instance # noqa: RET504 -@pytest.fixture() +@pytest.fixture def _provisioner_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"provisioner": {"name": "ansible", "env": {"FOO": "bar"}}} -@pytest.fixture() +@pytest.fixture def _verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"verifier": {"name": "ansible", "env": {"FOO": "bar"}}} -@pytest.fixture() +@pytest.fixture def _provisioner_verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "provisioner": {"name": "ansible", "env": {"FOO": "bar"}}, @@ -52,7 +52,7 @@ def _provisioner_verifier_section_data(): # type: ignore[no-untyped-def] # noq } -@pytest.fixture() +@pytest.fixture def _instance_for_verifier_env(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN202 _instance = ansible_playbook.AnsiblePlaybook("playbook", config_instance, True) # noqa: FBT003 return _instance # noqa: RET504 @@ -85,7 +85,7 @@ def test_env_in_verify_override_provision(_instance_for_verifier_env): # type: assert _instance_for_verifier_env._env["FOO"] == "baz" -@pytest.fixture() +@pytest.fixture def _inventory_directory(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 return _instance._config.provisioner.inventory_directory diff --git a/tests/unit/provisioner/test_ansible_playbooks.py b/tests/unit/provisioner/test_ansible_playbooks.py index 72c35999c..fe1fd30b7 100644 --- a/tests/unit/provisioner/test_ansible_playbooks.py +++ b/tests/unit/provisioner/test_ansible_playbooks.py @@ -28,12 +28,12 @@ from tests.unit.conftest import os_split # pylint:disable=C0411 -@pytest.fixture() +@pytest.fixture def _provisioner_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"provisioner": {"name": "ansible", "options": {}, "config_options": {}}} -@pytest.fixture() +@pytest.fixture def _instance(_provisioner_section_data, config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 return ansible_playbooks.AnsiblePlaybooks(config_instance) @@ -99,7 +99,7 @@ def test_get_playbook_returns_bundled_driver_playbook_when_local_not_found( # t assert x == _instance._get_playbook("create") -@pytest.fixture() +@pytest.fixture def _provisioner_driver_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "provisioner": { @@ -111,7 +111,7 @@ def _provisioner_driver_section_data(): # type: ignore[no-untyped-def] # noqa: } -@pytest.fixture() +@pytest.fixture def _provisioner_driver_playbook_key_missing_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "provisioner": { diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 286ca1641..9518dbe9a 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -98,7 +98,7 @@ def test_dependency_property(config_instance: config.Config) -> None: # noqa: D assert isinstance(config_instance.dependency, ansible_galaxy.AnsibleGalaxy) -@pytest.fixture() +@pytest.fixture def _config_dependency_shell_section_data() -> dict[Literal["dependency"], DependencyData]: return {"dependency": {"name": "shell", "command": "bin/command"}} @@ -112,7 +112,7 @@ def test_dependency_property_is_shell(config_instance: config.Config) -> None: assert isinstance(config_instance.dependency, shell.Shell) -@pytest.fixture() +@pytest.fixture def _config_driver_delegated_section_data() -> dict[Literal["driver"], DriverData]: return {"driver": {"name": "default", "options": {"managed": False}}} diff --git a/tests/unit/test_interpolation.py b/tests/unit/test_interpolation.py index 520d99468..254515337 100644 --- a/tests/unit/test_interpolation.py +++ b/tests/unit/test_interpolation.py @@ -18,7 +18,7 @@ from molecule import interpolation -@pytest.fixture() +@pytest.fixture def _mock_env(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "FOO": "foo", @@ -29,7 +29,7 @@ def _mock_env(): # type: ignore[no-untyped-def] # noqa: ANN202 } -@pytest.fixture() +@pytest.fixture def _instance(_mock_env): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 return interpolation.Interpolator(interpolation.TemplateWithDefaults, _mock_env) diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py index 069a2e521..80722c0bf 100644 --- a/tests/unit/test_logger.py +++ b/tests/unit/test_logger.py @@ -42,19 +42,19 @@ def execute(self, action_args=None): # type: ignore[no-untyped-def] # noqa: AN return True -@pytest.fixture() +@pytest.fixture def _dummy_class(patched_config_validate, config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202, ARG001 return Dummy -@pytest.fixture() +@pytest.fixture def _instance(_dummy_class, config_instance, _patched_logger_env): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 # _patched_logger_env included here to ensure pytest runs it first get_section_loggers.cache_clear() return _dummy_class(config_instance) -@pytest.fixture() +@pytest.fixture def _patched_logger_env(request, monkeypatch): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 """Parametrize tests with and without CI env vars.""" envvars = {"CI": None, "GITHUB_ACTIONS": None, "GITLAB_CI": None, "TRAVIS": None} diff --git a/tests/unit/test_platforms.py b/tests/unit/test_platforms.py index 4bf41b3ba..c5bcc5d1a 100644 --- a/tests/unit/test_platforms.py +++ b/tests/unit/test_platforms.py @@ -24,7 +24,7 @@ from molecule import config, platforms -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN202 return platforms.Platforms(config_instance) diff --git a/tests/unit/test_scenario.py b/tests/unit/test_scenario.py index 203373aaf..c2c5ad2f3 100644 --- a/tests/unit/test_scenario.py +++ b/tests/unit/test_scenario.py @@ -37,7 +37,7 @@ # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance( patched_config_validate: Mock, # noqa: ARG001 config_instance: config.Config, diff --git a/tests/unit/test_scenarios.py b/tests/unit/test_scenarios.py index 2bbe803af..a1425a03b 100644 --- a/tests/unit/test_scenarios.py +++ b/tests/unit/test_scenarios.py @@ -28,7 +28,7 @@ from molecule.text import chomp, strip_ansi_escape -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config) -> scenarios.Scenarios: config_instance_1 = copy.deepcopy(config_instance) diff --git a/tests/unit/test_scenarios_ordered.py b/tests/unit/test_scenarios_ordered.py index cf217db52..c575e13c7 100644 --- a/tests/unit/test_scenarios_ordered.py +++ b/tests/unit/test_scenarios_ordered.py @@ -26,7 +26,7 @@ from molecule import config, scenarios -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN202 config_instance_1 = copy.deepcopy(config_instance) config_instance_1.config["scenario"]["name"] = "two" diff --git a/tests/unit/test_state.py b/tests/unit/test_state.py index 596b4568e..103b95bbc 100644 --- a/tests/unit/test_state.py +++ b/tests/unit/test_state.py @@ -32,7 +32,7 @@ from typing import Any -@pytest.fixture() +@pytest.fixture def _instance(config_instance: config.Config) -> state.State: return state.State(config_instance) diff --git a/tests/unit/test_status.py b/tests/unit/test_status.py index 4bb890d30..2b292d07c 100644 --- a/tests/unit/test_status.py +++ b/tests/unit/test_status.py @@ -24,7 +24,7 @@ from molecule.status import Status -@pytest.fixture() +@pytest.fixture def _instance(): # type: ignore[no-untyped-def] # noqa: ANN202 s = Status( instance_name=None, # type: ignore[arg-type] diff --git a/tests/unit/verifier/test_ansible.py b/tests/unit/verifier/test_ansible.py index b58fe4425..4a1e540d8 100644 --- a/tests/unit/verifier/test_ansible.py +++ b/tests/unit/verifier/test_ansible.py @@ -10,7 +10,7 @@ from molecule.verifier import ansible -@pytest.fixture() +@pytest.fixture def _patched_ansible_verify(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 m = mocker.patch("molecule.provisioner.ansible.Ansible.verify") m.return_value = "patched-ansible-verify-stdout" @@ -18,7 +18,7 @@ def _patched_ansible_verify(mocker): # type: ignore[no-untyped-def] # noqa: AN return m -@pytest.fixture() +@pytest.fixture def _verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"verifier": {"name": "ansible", "env": {"FOO": "bar"}}} @@ -26,7 +26,7 @@ def _verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance( # type: ignore[no-untyped-def] # noqa: ANN202 _verifier_section_data, # noqa: ANN001 patched_config_validate, # noqa: ANN001, ARG001 diff --git a/tests/unit/verifier/test_testinfra.py b/tests/unit/verifier/test_testinfra.py index 29fb20867..8ef2815be 100644 --- a/tests/unit/verifier/test_testinfra.py +++ b/tests/unit/verifier/test_testinfra.py @@ -27,7 +27,7 @@ from molecule.verifier import testinfra -@pytest.fixture() +@pytest.fixture def _patched_testinfra_get_tests(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202 m = mocker.patch("molecule.verifier.testinfra.Testinfra._get_tests") m.return_value = ["foo.py", "bar.py"] @@ -35,7 +35,7 @@ def _patched_testinfra_get_tests(mocker): # type: ignore[no-untyped-def] # noq return m -@pytest.fixture() +@pytest.fixture def _verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return { "verifier": { @@ -50,12 +50,12 @@ def _verifier_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 # NOTE(retr0h): The use of the `patched_config_validate` fixture, disables # config.Config._validate from executing. Thus preventing odd side-effects # throughout patched.assert_called unit tests. -@pytest.fixture() +@pytest.fixture def _instance(patched_config_validate, config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN202, ARG001 return testinfra.Testinfra(config_instance) -@pytest.fixture() +@pytest.fixture def inventory_file(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 return _instance._config.provisioner.inventory_file @@ -165,7 +165,7 @@ def test_testinfra_directory_property(_instance): # type: ignore[no-untyped-def assert parts[-3:] == ["molecule", "default", "tests"] -@pytest.fixture() +@pytest.fixture def _verifier_testinfra_directory_section_data(): # type: ignore[no-untyped-def] # noqa: ANN202 return {"verifier": {"name": "testinfra", "directory": "/tmp/foo/bar"}} # noqa: S108