Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't expect D103 from tests #4289

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"_version.py" = ["SIM108"]
"tests/**" = ["SLF001", "S101", "S602", "T201"]
"tests/**" = ["D103", "SLF001", "S101", "S602", "T201"]

[tool.ruff.lint.pydocstyle]
convention = "google"
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
)


def is_subset(subset, superset): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
def is_subset(subset, superset): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201
# Checks if first dict is a subset of the second one
if isinstance(subset, dict):
return all(
Expand Down Expand Up @@ -76,7 +76,7 @@ def resources_folder_path() -> Path:
return FIXTURES_DIR / "resources"


def pytest_collection_modifyitems(items, config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
def pytest_collection_modifyitems(items, config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201
marker = config.getoption("-m")
is_sharded = False
shard_id = 0
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@


@pytest.fixture(name="scenario_to_test")
def fixture_scenario_to_test(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
def fixture_scenario_to_test(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201
return request.param


@pytest.fixture(name="scenario_name")
def fixture_scenario_name(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
def fixture_scenario_name(request): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201
try:
return request.param
except AttributeError:
return None


@pytest.fixture(name="driver_name")
def fixture_driver_name(request: FixtureRequest) -> str | None: # noqa: D103
def fixture_driver_name(request: FixtureRequest) -> str | None:
try:
# https://stackoverflow.com/q/65334215/99834
return request.param # type: ignore # noqa: PGH003
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/command/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@


@pytest.fixture()
def command_patched_ansible_create(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
def command_patched_ansible_create(mocker): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201
return mocker.patch("molecule.provisioner.ansible.Ansible.create")


@pytest.fixture()
def command_driver_delegated_section_data(): # type: ignore[no-untyped-def] # noqa: ANN201, D103
def command_driver_delegated_section_data(): # type: ignore[no-untyped-def] # noqa: ANN201
x = {
"driver": {
"name": "default",
Expand All @@ -43,5 +43,5 @@ def command_driver_delegated_section_data(): # type: ignore[no-untyped-def] #


@pytest.fixture()
def command_driver_delegated_managed_section_data(): # type: ignore[no-untyped-def] # noqa: ANN201, D103
def command_driver_delegated_managed_section_data(): # type: ignore[no-untyped-def] # noqa: ANN201
return {"driver": {"name": "default", "managed": True}}
2 changes: 1 addition & 1 deletion tests/unit/command/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _patched_ansible_check(mocker): # type: ignore[no-untyped-def] # noqa: ANN
# 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.
def test_check_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_check_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001
_patched_ansible_check, # noqa: ANN001, PT019
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/command/test_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _patched_ansible_cleanup(mocker): # type: ignore[no-untyped-def] # noqa: A
["_command_provisioner_section_with_cleanup_data"], # noqa: PT007
indirect=True,
)
def test_cleanup_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_cleanup_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
_patched_ansible_cleanup, # noqa: ANN001, PT019
caplog, # noqa: ANN001
Expand All @@ -69,7 +69,7 @@ def test_cleanup_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
_patched_ansible_cleanup.assert_called_once_with()


def test_cleanup_execute_skips_when_playbook_not_configured( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_cleanup_execute_skips_when_playbook_not_configured( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
_patched_ansible_cleanup, # noqa: ANN001, PT019
config_instance: config.Config,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/command/test_converge.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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.
def test_converge_execute( # noqa: D103
def test_converge_execute(
mocker: MockerFixture, # noqa: ARG001
caplog: pytest.LogCaptureFixture,
patched_ansible_converge: Mock,
Expand All @@ -58,7 +58,7 @@ def test_converge_execute( # noqa: D103
assert config_instance.state.converged


def test_ansible_args_passed_to_scenarios_get_configs(mocker: MockerFixture) -> None: # noqa: D103
def test_ansible_args_passed_to_scenarios_get_configs(mocker: MockerFixture) -> None:
# Scenarios patch is needed to safely invoke CliRunner
# in the test environment and block scenario execution
mocker.patch("molecule.scenarios.Scenarios")
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/command/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _patched_create_setup(mocker): # type: ignore[no-untyped-def] # noqa: ANN0
# config.Config._validate from executing. Thus preventing odd side-effects
# throughout patched.assert_called unit tests.
@pytest.mark.skip(reason="create not running for delegated")
def test_create_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_create_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001
command_patched_ansible_create, # noqa: ANN001
Expand All @@ -62,7 +62,7 @@ def test_create_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103


@pytest.mark.skip(reason="create not running for delegated")
def test_execute_skips_when_instances_already_created( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_execute_skips_when_instances_already_created( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
command_patched_ansible_create, # noqa: ANN001
config_instance: config.Config,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/command/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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.
def test_dependency_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_dependency_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001
patched_ansible_galaxy, # noqa: ANN001
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/command/test_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _patched_destroy_setup(mocker): # type: ignore[no-untyped-def] # noqa: ANN
# config.Config._validate from executing. Thus preventing odd side-effects
# throughout patched.assert_called unit tests.
@pytest.mark.skip(reason="destroy not running for delegated")
def test_destroy_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_destroy_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001
patched_config_validate, # noqa: ANN001, ARG001
Expand All @@ -71,7 +71,7 @@ def test_destroy_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
["command_driver_delegated_section_data"], # noqa: PT007
indirect=True,
)
def test_execute_skips_when_destroy_strategy_is_never( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_execute_skips_when_destroy_strategy_is_never( # type: ignore[no-untyped-def] # noqa: ANN201
_patched_destroy_setup, # noqa: ANN001, PT019
caplog, # noqa: ANN001
_patched_ansible_destroy, # noqa: ANN001, PT019
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/command/test_idempotence.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _instance(patched_config_validate, config_instance: config.Config): # type:
return idempotence.Idempotence(config_instance)


def test_idempotence_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_idempotence_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog: pytest.LogCaptureFixture,
patched_ansible_converge, # noqa: ANN001
Expand All @@ -69,7 +69,7 @@ def test_idempotence_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D
assert msg in caplog.text


def test_execute_raises_when_not_converged( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_execute_raises_when_not_converged( # type: ignore[no-untyped-def] # noqa: ANN201
caplog: pytest.LogCaptureFixture,
patched_ansible_converge, # noqa: ANN001, ARG001
_instance, # noqa: ANN001, PT019
Expand All @@ -84,7 +84,7 @@ def test_execute_raises_when_not_converged( # type: ignore[no-untyped-def] # n
assert msg in caplog.text


def test_execute_raises_when_fails_idempotence( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_execute_raises_when_fails_idempotence( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog: pytest.LogCaptureFixture,
patched_ansible_converge, # noqa: ANN001, ARG001
Expand All @@ -101,7 +101,7 @@ def test_execute_raises_when_fails_idempotence( # type: ignore[no-untyped-def]
assert msg in caplog.text


def test_is_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_is_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
output = """
PLAY RECAP ***********************************************************
check-command-01: ok=3 changed=0 unreachable=0 failed=0
Expand All @@ -110,7 +110,7 @@ def test_is_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN0
assert _instance._is_idempotent(output)


def test_is_idempotent_not_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_is_idempotent_not_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
output = """
PLAY RECAP ***********************************************************
check-command-01: ok=2 changed=1 unreachable=0 failed=0
Expand All @@ -120,7 +120,7 @@ def test_is_idempotent_not_idempotent(_instance): # type: ignore[no-untyped-def
assert not _instance._is_idempotent(output)


def test_non_idempotent_tasks_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_non_idempotent_tasks_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
output = """
PLAY [all] ***********************************************************

Expand All @@ -138,7 +138,7 @@ def test_non_idempotent_tasks_idempotent(_instance): # type: ignore[no-untyped-
assert result == []


def test_non_idempotent_tasks_not_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_non_idempotent_tasks_not_idempotent(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
output = """
PLAY [all] ***********************************************************

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/command/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from molecule import config


def test_list_execute(capsys, config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, ARG001, D103
def test_list_execute(capsys, config_instance: config.Config): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, ARG001
l = list.List(config_instance) # noqa: E741
x = [
base.Status( # type: ignore[attr-defined]
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/command/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _instance(config_instance: config.Config): # type: ignore[no-untyped-def]
return login.Login(config_instance)


def test_login_execute(mocker: MockerFixture, _instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_login_execute(mocker: MockerFixture, _instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "instance-1"}
m = mocker.patch("molecule.command.login.Login._get_login")
_instance.execute()
Expand All @@ -52,7 +52,7 @@ def test_login_execute(mocker: MockerFixture, _instance): # type: ignore[no-unt
["command_driver_delegated_managed_section_data"], # noqa: PT007
indirect=True,
)
def test_login_execute_instance_creation(mocker: MockerFixture, _instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_login_execute_instance_creation(mocker: MockerFixture, _instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "instance-1"}
_instance._config.state.change_state("created", False) # noqa: FBT003

Expand All @@ -68,7 +68,7 @@ def test_login_execute_instance_creation(mocker: MockerFixture, _instance): # t
assert _instance._config.state.created


def test_get_hostname_does_not_match(caplog, _instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_get_hostname_does_not_match(caplog, _instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "invalid"}
hosts = ["instance-1"]
with pytest.raises(SystemExit) as e:
Expand All @@ -80,35 +80,35 @@ def test_get_hostname_does_not_match(caplog, _instance): # type: ignore[no-unty
assert msg in caplog.text


def test_get_hostname_exact_match_with_one_host(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_get_hostname_exact_match_with_one_host(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "instance-1"}
hosts = ["instance-1"]

assert _instance._get_hostname(hosts) == "instance-1"


def test_get_hostname_partial_match_with_one_host(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_get_hostname_partial_match_with_one_host(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "inst"}
hosts = ["instance-1"]

assert _instance._get_hostname(hosts) == "instance-1"


def test_get_hostname_exact_match_with_multiple_hosts(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_get_hostname_exact_match_with_multiple_hosts(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "instance-1"}
hosts = ["instance-1", "instance-2"]

assert _instance._get_hostname(hosts) == "instance-1"


def test_get_hostname_partial_match_with_multiple_hosts(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_get_hostname_partial_match_with_multiple_hosts(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {"host": "foo"}
hosts = ["foo", "fooo"]

assert _instance._get_hostname(hosts) == "foo"


def test_get_hostname_partial_match_with_multiple_hosts_raises( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_get_hostname_partial_match_with_multiple_hosts_raises( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
_instance, # noqa: ANN001, PT019
):
Expand All @@ -129,15 +129,15 @@ def test_get_hostname_partial_match_with_multiple_hosts_raises( # type: ignore[
assert msg in caplog.text


def test_get_hostname_no_host_flag_specified_on_cli(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
def test_get_hostname_no_host_flag_specified_on_cli(_instance): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019
_instance._config.command_args = {}
hosts = ["instance-1"]
_instance._get_hostname(hosts)

assert _instance._get_hostname(hosts) == "instance-1"


def test_get_hostname_no_host_flag_specified_on_cli_with_multiple_hosts_raises( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_get_hostname_no_host_flag_specified_on_cli_with_multiple_hosts_raises( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
_instance, # noqa: ANN001, PT019
):
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/command/test_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _patched_ansible_prepare(mocker): # type: ignore[no-untyped-def] # noqa: A
# 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.
def test_prepare_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_prepare_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001
_patched_ansible_prepare, # noqa: ANN001, PT019
Expand All @@ -62,7 +62,7 @@ def test_prepare_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
assert config_instance.state.prepared


def test_execute_skips_when_instances_already_prepared( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_execute_skips_when_instances_already_prepared( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
_patched_ansible_prepare, # noqa: ANN001, PT019
config_instance: config.Config,
Expand All @@ -77,7 +77,7 @@ def test_execute_skips_when_instances_already_prepared( # type: ignore[no-untyp
assert not _patched_ansible_prepare.called


def test_prepare_execute_skips_when_playbook_not_configured( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_prepare_execute_skips_when_playbook_not_configured( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
_patched_ansible_prepare, # noqa: ANN001, PT019
config_instance: config.Config,
Expand All @@ -91,7 +91,7 @@ def test_prepare_execute_skips_when_playbook_not_configured( # type: ignore[no-
assert not _patched_ansible_prepare.called


def test_execute_when_instances_already_prepared_but_force_provided( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_execute_when_instances_already_prepared_but_force_provided( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001, ARG001
_patched_ansible_prepare, # noqa: ANN001, PT019
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/command/test_side_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _patched_ansible_side_effect(mocker): # type: ignore[no-untyped-def] # noq
["_command_provisioner_section_with_side_effect_data"], # noqa: PT007
indirect=True,
)
def test_side_effect_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_side_effect_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
_patched_ansible_side_effect, # noqa: ANN001, PT019
caplog, # noqa: ANN001
Expand All @@ -75,7 +75,7 @@ def test_side_effect_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D
_patched_ansible_side_effect.assert_called_once_with(None)


def test_side_effect_execute_skips_when_playbook_not_configured( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_side_effect_execute_skips_when_playbook_not_configured( # type: ignore[no-untyped-def] # noqa: ANN201
caplog, # noqa: ANN001
_patched_ansible_side_effect, # noqa: ANN001, PT019
config_instance: config.Config,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/command/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _patched_ansible_syntax(mocker): # type: ignore[no-untyped-def] # noqa: AN
# 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.
def test_syntax_execute( # type: ignore[no-untyped-def] # noqa: ANN201, D103
def test_syntax_execute( # type: ignore[no-untyped-def] # noqa: ANN201
mocker: MockerFixture, # noqa: ARG001
caplog, # noqa: ANN001
_patched_ansible_syntax, # noqa: ANN001, PT019
Expand Down
Loading
Loading