Cosmetic fixes to make flak8 happy

This commit is contained in:
(GalaxyMaster) 2020-04-14 22:06:11 +10:00
commit 39bd1e48be
2 changed files with 8 additions and 5 deletions

View file

@ -529,17 +529,18 @@ def configure_settings(settings):
preserved = {}
logger.debug('Theme provides a config `%s`', theme_config)
# preserve variables that are dynamically calculated in read_settings()
for p in ['PATH', 'OUTPUT_PATH', 'THEME', 'CACHE_PATH', 'PLUGIN_PATHS']:
for p in ['PATH', 'OUTPUT_PATH', 'THEME', 'CACHE_PATH',
'PLUGIN_PATHS']:
if settings.get(p) is not None:
preserved[p] = settings.get(p)
settings.pop('THEME') # avoid recursion
settings.pop('THEME') # avoid recursion
settings = read_settings(theme_config, settings)
# restore them back to look like we did not calculate them again
for p in ['PATH', 'OUTPUT_PATH', 'THEME', 'CACHE_PATH', 'PLUGIN_PATHS']:
for p in ['PATH', 'OUTPUT_PATH', 'THEME', 'CACHE_PATH',
'PLUGIN_PATHS']:
if preserved.get(p) is not None:
settings[p] = preserved.pop(p)
# make paths selected for writing absolute if necessary
settings['WRITE_SELECTED'] = [
os.path.abspath(path) for path in

View file

@ -6,12 +6,14 @@ import os
from os.path import abspath, dirname, join
from sys import platform
from pelican.settings import (DEFAULT_CONFIG, DEFAULT_THEME,
_printf_s_to_format_field,
configure_settings, handle_deprecated_settings,
read_settings)
from pelican.tests.support import unittest
class TestSettingsConfiguration(unittest.TestCase):
"""Provided a file, it should read it, replace the default values,
append new values to the settings (if any), and apply basic settings
@ -72,7 +74,7 @@ class TestSettingsConfiguration(unittest.TestCase):
expected = copy.deepcopy(self.settings)
expected['THEME'] = os.path.join(self.PATH, 'themes/custom')
expected['CUSTOM_THEME_SETTING'] = 'test'
settings = read_settings(default_conf, { 'THEME': 'themes/custom' } )
settings = read_settings(default_conf, {'THEME': 'themes/custom'})
self.maxDiff = None
self.assertDictEqual(settings, expected)