diff --git a/reno/config.py b/reno/config.py index 03ae26b..3aa6583 100644 --- a/reno/config.py +++ b/reno/config.py @@ -218,7 +218,7 @@ class Config(object): if os.path.isfile(filename): break else: - LOG.info('no configuration file in: %s', ', '.join(filenames)) + self._report_missing_config_files(filenames) return try: @@ -226,10 +226,20 @@ class Config(object): self._contents = yaml.safe_load(fd) LOG.info('loaded configuration file %s', filename) except IOError as err: - LOG.warning('did not load config file %s: %s', filename, err) + self._report_failure_config_file(filename, err) else: self.override(**self._contents) + def _report_missing_config_files(self, filenames): + # NOTE(dhellmann): This is extracted so we can mock it for + # testing. + LOG.info('no configuration file in: %s', ', '.join(filenames)) + + def _report_failure_config_file(self, filename, err): + # NOTE(dhellmann): This is extracted so we can mock it for + # testing. + LOG.warning('did not load config file %s: %s', filename, err) + def _rename_prelude_section(self, **kwargs): key = 'prelude_section_name' if key in kwargs and kwargs[key] != self._OPTS[key].default: diff --git a/reno/tests/test_config.py b/reno/tests/test_config.py index 39cf94e..6251aa7 100644 --- a/reno/tests/test_config.py +++ b/reno/tests/test_config.py @@ -73,9 +73,10 @@ collapse_pre_releases: false self.assertEqual(expected, actual) def test_load_file_not_present(self): - with mock.patch.object(config.LOG, 'info') as logger: + missing = 'reno.config.Config._report_missing_config_files' + with mock.patch(missing) as error_handler: config.Config(self.tempdir.path) - self.assertEqual(1, logger.call_count) + self.assertEqual(1, error_handler.call_count) def _test_load_file(self, config_path): with open(config_path, 'w') as fd: