config: Only load .conf-files when loading directories
This commit is contained in:
parent
9e41eff187
commit
584484379a
@ -120,7 +120,7 @@ def _load(files, defaults, overrides):
|
||||
if os.path.isdir(name):
|
||||
for filename in os.listdir(name):
|
||||
filename = os.path.join(name, filename)
|
||||
if os.path.isfile(filename):
|
||||
if os.path.isfile(filename) and filename.endswith('.conf'):
|
||||
_load_file(parser, filename)
|
||||
else:
|
||||
_load_file(parser, name)
|
||||
|
||||
@ -61,11 +61,17 @@ class LoadConfigTest(unittest.TestCase):
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_load_directory(self):
|
||||
directory = path_to_data_dir('conf.d')
|
||||
directory = path_to_data_dir('conf1.d')
|
||||
expected = {'foo': {'bar': 'baz'}, 'foo2': {'bar': 'baz'}}
|
||||
result = config._load([directory], [], [])
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_load_directory_only_conf_files(self):
|
||||
directory = path_to_data_dir('conf2.d')
|
||||
expected = {'foo': {'bar': 'baz'}}
|
||||
result = config._load([directory], [], [])
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_load_file_with_utf8(self):
|
||||
expected = {'foo': {'bar': 'æøå'.encode('utf-8')}}
|
||||
result = config._load([path_to_data_dir('file3.conf')], [], [])
|
||||
|
||||
2
tests/data/conf2.d/file1.conf
Normal file
2
tests/data/conf2.d/file1.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[foo]
|
||||
bar = baz
|
||||
2
tests/data/conf2.d/file2.conf.disabled
Normal file
2
tests/data/conf2.d/file2.conf.disabled
Normal file
@ -0,0 +1,2 @@
|
||||
[foo2]
|
||||
bar = baz
|
||||
Loading…
Reference in New Issue
Block a user