Fix the LOG_FILTER setting

This commit is contained in:
Ascani Carlo 2020-01-13 15:17:05 +01:00
commit 3bad5f9854
3 changed files with 20 additions and 1 deletions

View file

@ -265,3 +265,21 @@ class TestPelican(LoggedTestCase):
sys.executable, '-m', 'pelican', '--help'
]).decode('ascii', 'replace')
assert 'usage:' in output
def test_log_filter(self):
settings = read_settings(path=SAMPLE_CONFIG, override={
'PATH': INPUT_PATH,
'OUTPUT_PATH': self.temp_path,
'LOCALE': locale.normalize('en_US'),
'LOG_FILTER': [
(logging.WARN, 'CATEGORY_SAVE_AS is set to False'),
(logging.WARN, 'AUTHOR_SAVE_AS is set to None'),
],
'CATEGORY_SAVE_AS': False,
'AUTHOR_SAVE_AS': None,
})
pelican = Pelican(settings=settings)
mute(True)(pelican.run)()
self.assertLogCountEqual(
count=0, # LOG_FILTER should filter out the log messages
level=logging.WARNING)

View file

@ -102,7 +102,7 @@ class URLWrapper(object):
setting = "%s_%s" % (self.__class__.__name__.upper(), key)
value = self.settings[setting]
if not isinstance(value, str):
logger.warning('%s is set to %s', setting, value)
logger.warning('%s is set to %s' % (setting, value))
return value
else:
if get_page_name:

View file

@ -188,6 +188,7 @@ class Writer(object):
if name is False or \
name == "" or \
name is None or \
not is_selected_for_writing(self.settings,
os.path.join(self.output_path, name)):
return