Add test cases to confirm implementation of mock_config()

This commit is contained in:
Patrick Lannigan 2023-10-01 10:44:26 -04:00
parent c93bc1e0ca
commit 64f72774de
No known key found for this signature in database
GPG Key ID: BBF5D9DED1E4AAF9
1 changed files with 35 additions and 0 deletions

View File

@ -38,6 +38,41 @@ def mock_config(verbose: int = 0, assertion_override: Optional[int] = None):
return Config()
class TestMockConfig:
SOME_VERBOSITY_LEVEL = 3
SOME_OTHER_VERBOSITY_LEVEL = 10
def test_verbose_exposes_value(self):
config = mock_config(verbose=TestMockConfig.SOME_VERBOSITY_LEVEL)
assert config.output_verbosity.verbose == TestMockConfig.SOME_VERBOSITY_LEVEL
def test_verbosity_for_assertion_override_not_set_verbose_value(self):
config = mock_config(verbose=TestMockConfig.SOME_VERBOSITY_LEVEL)
assert (
config.output_verbosity.verbosity_for("assertions")
== TestMockConfig.SOME_VERBOSITY_LEVEL
)
def test_verbosity_for_assertion_override_set_custom_value(self):
config = mock_config(
verbose=TestMockConfig.SOME_VERBOSITY_LEVEL,
assertion_override=TestMockConfig.SOME_OTHER_VERBOSITY_LEVEL,
)
assert (
config.output_verbosity.verbosity_for("assertions")
== TestMockConfig.SOME_OTHER_VERBOSITY_LEVEL
)
def test_verbosity_for_unsupported_type_error(self):
config = mock_config(verbose=TestMockConfig.SOME_VERBOSITY_LEVEL)
with pytest.raises(KeyError):
config.output_verbosity.verbosity_for("NOT CONFIGURED NAME")
class TestImportHookInstallation:
@pytest.mark.parametrize("initial_conftest", [True, False])
@pytest.mark.parametrize("mode", ["plain", "rewrite"])