diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 09cdc0ca..5611c717 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -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) diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 6a0ee12b..da0e5192 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -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')], [], []) diff --git a/tests/data/conf.d/file1.conf b/tests/data/conf1.d/file1.conf similarity index 100% rename from tests/data/conf.d/file1.conf rename to tests/data/conf1.d/file1.conf diff --git a/tests/data/conf.d/file2.conf b/tests/data/conf1.d/file2.conf similarity index 100% rename from tests/data/conf.d/file2.conf rename to tests/data/conf1.d/file2.conf diff --git a/tests/data/conf2.d/file1.conf b/tests/data/conf2.d/file1.conf new file mode 100644 index 00000000..e6396bff --- /dev/null +++ b/tests/data/conf2.d/file1.conf @@ -0,0 +1,2 @@ +[foo] +bar = baz diff --git a/tests/data/conf2.d/file2.conf.disabled b/tests/data/conf2.d/file2.conf.disabled new file mode 100644 index 00000000..ef189703 --- /dev/null +++ b/tests/data/conf2.d/file2.conf.disabled @@ -0,0 +1,2 @@ +[foo2] +bar = baz