1
0
Fork 0
forked from github/pelican

tests.support: Use kwargs overrides in get_settings()

This avoids harcoding test-specific overrides, and makes it easy to
setup a settings dictionary based on DEFAULT_CONFIG for testing.
Because you can trust Pelican to use settings based on DEFAULT_CONFIG,
you are free to go about using:

  settings[my_key]

instead of:

  settings.get(my_key, some_fallback)

or:

  if my_key in settings:
      ...

if you know that `my_key` is in DEFAULT_CONFIG.
This commit is contained in:
W. Trevor King 2013-03-24 15:08:33 -04:00
commit c8e7d95b34
4 changed files with 66 additions and 68 deletions

View file

@ -161,10 +161,14 @@ def locale_available(locale_):
return True
def get_settings():
def get_settings(**kwargs):
"""Provide tweaked setting dictionaries for testing
Set keyword arguments to override specific settings.
"""
settings = DEFAULT_CONFIG.copy()
settings['DIRECT_TEMPLATES'] = ['archives']
settings['filenames'] = {}
for key,value in kwargs.items():
settings[key] = value
return settings