@contextmanager<EOL>def patch_conf(settings_patch=None, settings_file=None):
if settings_patch is None:<EOL><INDENT>settings_patch = {}<EOL><DEDENT>reload_config()<EOL>os.environ[ENVIRONMENT_VARIABLE] = settings_file if settings_file else '<STR_LIT>'<EOL>from bernard.conf import settings as l_settings<EOL>r_settings = l_settings._settings<EOL>r_settings.update(settings_patch)<EOL>if '<STR_LIT>' in modules:<EOL><INDENT>from bernard.i18n import translate, intents<EOL>translate._regenerate_word_dict()<EOL>intents._refresh_intents_db()<EOL><DEDENT>yield<EOL>
Reload the configuration form scratch. Only the default config is loaded,
not the environment-specified config.

Then the specified patch is applied.

This is for unit tests only!

:param settings_patch: Custom configuration values to insert
:param settings_file: Custom settings file to read