diff --git a/autoregistry/config.py b/autoregistry/config.py index 5d00bc5..6e80bba 100644 --- a/autoregistry/config.py +++ b/autoregistry/config.py @@ -57,6 +57,8 @@ def update(self, new: dict) -> None: for key, value in new.items(): if hasattr(self, key): setattr(self, key, value) + else: + raise TypeError(f"Unexpected configuration value {key}={value}") def getitem(self, registry: dict, key: str): """Key/Value lookup with keysplitting and optional case-insensitivity.""" diff --git a/tests/test_classes_config.py b/tests/test_classes_config.py index c064b69..f402c77 100644 --- a/tests/test_classes_config.py +++ b/tests/test_classes_config.py @@ -4,6 +4,14 @@ from autoregistry import InvalidNameError, Registry +def test_typo(): + # Make sure we catch invalid parameters + with pytest.raises(TypeError): + + class Sensor(Registry, asdklfjlk=123): + pass + + def test_case_sensitive(): Pokemon, Charmander, Pikachu, SurfingPikachu = construct_pokemon_classes( case_sensitive=True, diff --git a/tests/test_misc.py b/tests/test_misc.py index 105215f..cdd2797 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -21,13 +21,23 @@ def test_registry_config_update(): config.update( { "suffix": "test", - "not_valid_config_key": None, # This should be ignored. } ) assert config.suffix == "test" +def test_registry_config_update_invalid_key(): + config = RegistryConfig() + with pytest.raises(TypeError): + config.update( + { + "suffix": "test", + "not_valid_config_key": None, # This should be ignored. + } + ) + + def test_registry_config_cannot_derive_name(): __registry__ = _Registry(RegistryConfig()) foo = "foo"