diff --git a/decouple.py b/decouple.py index f499862..9873fc9 100644 --- a/decouple.py +++ b/decouple.py @@ -219,7 +219,7 @@ def _find_file(self, path): # search the parent parent = os.path.dirname(path) - if parent and parent != os.path.abspath(os.sep): + if parent and os.path.normcase(parent) != os.path.normcase(os.path.abspath(os.sep)): return self._find_file(parent) # reached root without finding any files. diff --git a/tests/test_autoconfig.py b/tests/test_autoconfig.py index 75d97c3..94af7cc 100644 --- a/tests/test_autoconfig.py +++ b/tests/test_autoconfig.py @@ -97,3 +97,13 @@ def test_autoconfig_env_default_encoding(): assert config.encoding == DEFAULT_ENCODING assert 'ENV' == config('KEY', default='ENV') mopen.assert_called_once_with(filename, encoding=DEFAULT_ENCODING) + + +def test_autoconfig_no_repository(): + path = os.path.join(os.path.dirname(__file__), 'autoconfig', 'ini', 'no_repository') + config = AutoConfig(path) + + with pytest.raises(UndefinedValueError): + config('KeyNotInEnvAndNotInRepository') + + assert isinstance(config.config.repository, RepositoryEmpty)