Skip to content

Commit

Permalink
Improve test names
Browse files Browse the repository at this point in the history
This fixes issues reported by newer version of pytest-plus.
  • Loading branch information
ssbarnea committed Oct 24, 2023
1 parent 8200cb3 commit 69a6904
Show file tree
Hide file tree
Showing 26 changed files with 126 additions and 116 deletions.
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/init/test_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _instance(_command_args):
return scenario.Scenario(_command_args)


def test_execute(temp_dir, _instance, patched_logger_info):
def test_scenario_execute(temp_dir, _instance, patched_logger_info):
_instance.execute()

msg = "Initializing new scenario test-scenario..."
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/command/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ def _patched_sysexit(mocker):
return mocker.patch("molecule.util.sysexit")


def test_config_private_member(_instance):
def test_command_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)


def test_init_calls_setup(_patched_base_setup, _instance):
_patched_base_setup.assert_called_once_with()


def test_setup(
def test_command_setup(
mocker: MockerFixture,
patched_add_or_update_vars,
_patched_write_config,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _patched_ansible_check(mocker):
# 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_execute(
def test_check_execute(
mocker: MockerFixture,
caplog,
_patched_ansible_check,
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/command/test_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _patched_ansible_cleanup(mocker):
["_command_provisioner_section_with_cleanup_data"],
indirect=True,
)
def test_execute(
def test_cleanup_execute(
mocker: MockerFixture,
_patched_ansible_cleanup,
caplog,
Expand All @@ -63,7 +63,7 @@ def test_execute(
_patched_ansible_cleanup.assert_called_once_with()


def test_execute_skips_when_playbook_not_configured(
def test_cleanup_execute_skips_when_playbook_not_configured(
caplog,
_patched_ansible_cleanup,
config_instance: config.Config,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_converge.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_execute(
def test_converge_execute(
mocker: MockerFixture,
caplog: LogCaptureFixture,
patched_ansible_converge: Mock,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _patched_create_setup(mocker):
# 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_execute(
def test_create_execute(
mocker: MockerFixture,
caplog,
command_patched_ansible_create,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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_execute(
def test_dependency_execute(
mocker: MockerFixture,
caplog,
patched_ansible_galaxy,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _patched_destroy_setup(mocker):
# 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_execute(
def test_destroy_execute(
mocker: MockerFixture,
caplog,
patched_config_validate,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_idempotence.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _instance(patched_config_validate, config_instance: config.Config):
return idempotence.Idempotence(config_instance)


def test_execute(
def test_idempotence_execute(
mocker: MockerFixture,
caplog: pytest.LogCaptureFixture,
patched_ansible_converge,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from molecule.driver import base


def test_execute(capsys, config_instance: config.Config):
def test_list_execute(capsys, config_instance: config.Config):
l = list.List(config_instance)
x = [
base.Status(
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _instance(config_instance: config.Config):
return login.Login(config_instance)


def test_execute(mocker: MockerFixture, _instance):
def test_login_execute(mocker: MockerFixture, _instance):
_instance._config.command_args = {"host": "instance-1"}
m = mocker.patch("molecule.command.login.Login._get_login")
_instance.execute()
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/command/test_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _patched_ansible_prepare(mocker):
# 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_execute(
def test_prepare_execute(
mocker: MockerFixture,
caplog,
_patched_ansible_prepare,
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_execute_skips_when_instances_already_prepared(
assert not _patched_ansible_prepare.called


def test_execute_skips_when_playbook_not_configured(
def test_prepare_execute_skips_when_playbook_not_configured(
caplog,
_patched_ansible_prepare,
config_instance: config.Config,
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/command/test_side_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _patched_ansible_side_effect(mocker):
["_command_provisioner_section_with_side_effect_data"],
indirect=True,
)
def test_execute(
def test_side_effect_execute(
mocker: MockerFixture,
_patched_ansible_side_effect,
caplog,
Expand All @@ -69,7 +69,7 @@ def test_execute(
_patched_ansible_side_effect.assert_called_once_with(None)


def test_execute_skips_when_playbook_not_configured(
def test_side_effect_execute_skips_when_playbook_not_configured(
caplog,
_patched_ansible_side_effect,
config_instance: config.Config,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _patched_ansible_syntax(mocker):
# 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_execute(
def test_syntax_execute(
mocker: MockerFixture,
caplog,
_patched_ansible_syntax,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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_execute(
def test_verify_execute(
mocker: MockerFixture,
caplog,
patched_default_verifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ def role_file(_instance):
return os.path.join(_instance._config.scenario.directory, "collections.yml")


def test_config_private_member(_instance):
def test_collections_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)


def test_default_options_property(_instance, role_file):
def test_collections_default_options_property(_instance, role_file):
x = {"requirements-file": role_file, "force": False}

assert x == _instance.default_options


def test_default_env_property(_instance):
def test_collections_default_env_property(_instance):
env = _instance.default_env

assert "MOLECULE_FILE" in env
Expand All @@ -84,16 +84,16 @@ def test_default_env_property(_instance):
assert "MOLECULE_INSTANCE_CONFIG" in env


def test_name_property(_instance):
def test_collections_name_property(_instance):
assert _instance.name == "galaxy"


def test_enabled_property(_instance):
def test_collections_enabled_property(_instance):
assert _instance.enabled


@pytest.mark.parametrize("config_instance", ["_dependency_section_data"], indirect=True)
def test_options_property(_instance, role_file):
def test_collections_options_property(_instance, role_file):
x = {
"force": False,
"requirements-file": role_file,
Expand All @@ -105,7 +105,7 @@ def test_options_property(_instance, role_file):


@pytest.mark.parametrize("config_instance", ["_dependency_section_data"], indirect=True)
def test_options_property_handles_cli_args(role_file, _instance):
def test_collections_options_property_handles_cli_args(role_file, _instance):
_instance._config.args = {"debug": True}
x = {
"force": False,
Expand All @@ -118,7 +118,7 @@ def test_options_property_handles_cli_args(role_file, _instance):


@pytest.mark.parametrize("config_instance", ["_dependency_section_data"], indirect=True)
def test_env_property(_instance):
def test_collections_env_property(_instance):
assert _instance.env["FOO"] == "bar"


Expand All @@ -138,7 +138,7 @@ def test_collections_bake(_instance, role_file):
assert _instance._sh_command == args


def test_execute(
def test_collections_execute(
patched_run_command,
_patched_ansible_galaxy_has_requirements_file,
caplog,
Expand All @@ -157,7 +157,7 @@ def test_execute(
assert msg in caplog.text


def test_execute_does_not_execute_when_disabled(
def test_collections_execute_does_not_execute_when_disabled(
patched_run_command,
caplog,
_instance,
Expand All @@ -171,7 +171,7 @@ def test_execute_does_not_execute_when_disabled(
assert msg in caplog.text


def test_execute_does_not_execute_when_no_requirements_file(
def test_collections_execute_does_not_execute_when_no_requirements_file(
patched_run_command,
_patched_ansible_galaxy_has_requirements_file,
caplog,
Expand All @@ -186,7 +186,7 @@ def test_execute_does_not_execute_when_no_requirements_file(
assert msg in caplog.text


def test_execute_bakes(
def test_collections_execute_bakes(
patched_run_command,
_instance,
role_file,
Expand All @@ -209,13 +209,13 @@ def test_collections_executes_catches_and_exits_return_code(
assert e.value.code == 1


def test_setup(_instance):
def test_collections_setup(_instance):
_instance._setup()


def test_role_file(role_file, _instance):
def test_collections_role_file(role_file, _instance):
assert role_file == _instance.requirements_file


def test_has_requirements_file(_instance):
def test_collections_has_requirements_file(_instance):
assert not _instance._has_requirements_file()
24 changes: 12 additions & 12 deletions src/molecule/test/a_unit/dependency/ansible_galaxy/test_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ def role_file(_instance):
return os.path.join(_instance._config.scenario.directory, "requirements.yml")


def test_config_private_member(_instance):
def test_roles_config_private_member(_instance):
assert isinstance(_instance._config, config.Config)


def test_default_options_property(_instance, role_file):
def test_roles_default_options_property(_instance, role_file):
x = {"role-file": role_file, "force": False}

assert x == _instance.default_options


def test_default_env_property(_instance):
def test_roles_default_env_property(_instance):
env = _instance.default_env

assert "MOLECULE_FILE" in env
Expand All @@ -83,16 +83,16 @@ def test_default_env_property(_instance):
assert "MOLECULE_INSTANCE_CONFIG" in env


def test_name_property(_instance):
def test_roles_name_property(_instance):
assert _instance.name == "galaxy"


def test_enabled_property(_instance):
def test_roles_enabled_property(_instance):
assert _instance.enabled


@pytest.mark.parametrize("config_instance", ["_dependency_section_data"], indirect=True)
def test_options_property(_instance, role_file):
def test_roles_options_property(_instance, role_file):
x = {
"force": False,
"role-file": role_file,
Expand All @@ -104,7 +104,7 @@ def test_options_property(_instance, role_file):


@pytest.mark.parametrize("config_instance", ["_dependency_section_data"], indirect=True)
def test_options_property_handles_cli_args(role_file, _instance):
def test_roles_options_property_handles_cli_args(role_file, _instance):
_instance._config.args = {"debug": True}
x = {
"force": False,
Expand All @@ -117,7 +117,7 @@ def test_options_property_handles_cli_args(role_file, _instance):


@pytest.mark.parametrize("config_instance", ["_dependency_section_data"], indirect=True)
def test_env_property(_instance):
def test_roles_env_property(_instance):
assert _instance.env["FOO"] == "bar"


Expand Down Expand Up @@ -155,7 +155,7 @@ def test_execute(
assert msg in caplog.text


def test_execute_does_not_execute_when_disabled(
def test_roles_execute_does_not_execute_when_disabled(
patched_run_command,
caplog,
_instance,
Expand All @@ -169,7 +169,7 @@ def test_execute_does_not_execute_when_disabled(
assert msg in caplog.text


def test_execute_does_not_execute_when_no_requirements_file(
def test_roles_execute_does_not_execute_when_no_requirements_file(
patched_run_command,
_patched_ansible_galaxy_has_requirements_file,
caplog,
Expand All @@ -184,7 +184,7 @@ def test_execute_does_not_execute_when_no_requirements_file(
assert msg in caplog.text


def test_execute_bakes(
def test_roles_execute_bakes(
patched_run_command,
_instance,
role_file,
Expand Down Expand Up @@ -212,5 +212,5 @@ def test_role_file(role_file, _instance):
assert role_file == _instance.requirements_file


def test_has_requirements_file(_instance):
def test_roles_has_requirements_file(_instance):
assert not _instance._has_requirements_file()
Loading

0 comments on commit 69a6904

Please sign in to comment.