Merge "Handle empty config files"

This commit is contained in:
Zuul 2020-04-30 06:52:28 +00:00 committed by Gerrit Code Review
commit 9410229b83
2 changed files with 10 additions and 1 deletions

View File

@ -234,7 +234,8 @@ class Config(object):
except IOError as err:
self._report_failure_config_file(filename, err)
else:
self.override(**self._contents)
if self._contents:
self.override(**self._contents)
def _report_missing_config_files(self, filenames):
# NOTE(dhellmann): This is extracted so we can mock it for

View File

@ -94,6 +94,14 @@ collapse_pre_releases: false
config_path = self.tempdir.join('reno.yaml')
self._test_load_file(config_path)
def test_load_file_empty(self):
config_path = self.tempdir.join('reno.yaml')
with open(config_path, 'w') as fd:
fd.write('# Add reno config here')
self.addCleanup(os.unlink, config_path)
c = config.Config(self.tempdir.path)
self.assertEqual(True, c.collapse_pre_releases)
def test_get_default(self):
d = config.Config.get_default('notesdir')
self.assertEqual('notes', d)