From 6777f02e066d666415e8190e47c09b0da912ac87 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 28 May 2024 22:55:53 -0500 Subject: [PATCH] Fix bug when default config paths do not exist when fetching initial path listing, to create config object. should only affect situations where default file paths are needed, i.e. when caller does not specify --- CHANGELOG.md | 2 ++ src/wuttjamaican/conf.py | 2 ++ tests/test_conf.py | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d1689..bfdde98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## Unreleased +### Changed +- Fix bug when default config paths do not exist. ## [0.1.11] - 2024-04-14 ### Changed diff --git a/src/wuttjamaican/conf.py b/src/wuttjamaican/conf.py index ee6ed4b..b022e4e 100644 --- a/src/wuttjamaican/conf.py +++ b/src/wuttjamaican/conf.py @@ -777,6 +777,8 @@ def get_config_paths( files = [default_files] else: files = list(default_files) + files = [path for path in files + if os.path.exists(path)] else: files = [] diff --git a/tests/test_conf.py b/tests/test_conf.py index c237377..e7a1933 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -437,6 +437,12 @@ winsvc.RattailFileMonitor = /path/to/other/file files = conf.get_config_paths(files=[myconf], winsvc='RattailFileMonitor') self.assertEqual(files, ['/path/to/other/file']) + def test_nonexistent_default_files(self): + files = conf.get_config_paths(files=None, + env_files_name='IGNORE_THIS', + default_files=['/this/does/not/exist']) + self.assertEqual(files, []) + class TestMakeConfig(FileConfigTestCase):