def test_misconfigured_object_path(self): settings = LazySettings('tests.samples.non_existing_module.Config') settings.add_strategy(SettingsLoadStrategyPythonObj) with pytest.raises(RuntimeError): settings.as_dict() settings = LazySettings('tests.samples.python_obj.non_existing_class') settings.add_strategy(SettingsLoadStrategyPythonObj) with pytest.raises(RuntimeError): settings.as_dict()
def test_dont_overwrite_special_settings_with_environ(self): expect_module = 'tests.samples.special' settings = LazySettings() with patch.object(sys, 'argv', []): with patch.dict('os.environ', {SPECIAL_SETTINGS_KEY: expect_module}): settings.setup() print(settings.as_dict()) assert isinstance(getattr(settings, SPECIAL_SETTINGS_KEY), dict)
def test_should_return_a_nice_repr(self): settings = LazySettings('tests.samples.simple') assert repr(settings) == '<SIMPLE-SETTINGS ({})>'.format( settings.as_dict())
def test_should_not_read_non_class_settings_value(self): settings = LazySettings('tests.samples.python_obj.config_invalid') settings.add_strategy(SettingsLoadStrategyPythonObj) with pytest.raises(RuntimeError): settings.as_dict()
def test_should_return_a_nice_repr(self): settings = LazySettings('tests.samples.simple') assert repr(settings) == '<SIMPLE-SETTINGS ({})>'.format( settings.as_dict() )