def test_load_config_local_and_style():
"""
Test `load_config()` with local and style configuration files. Local file
should always override style, which should override template.
"""
with TemporaryDirectory() as tmpdir:
tmpdir = Path(tmpdir)
# Change home directory for testing
os.environ['MARKDOWNREVEAL_HOME'] = str(tmpdir)
# Create local configuration file
config_file = tmpdir / 'config.yaml'
config_file.write_text('footer: "local footer"')
# Create style configuration file
style_path = tmpdir / '.markdownreveal' / 'out' / 'markdownrevealstyle'
style_path.mkdir(parents=True)
config_file = style_path / 'config.yaml'
config_file.write_text('footer: "style footer"\n'
'header: "style header"')
# Load configuration
old = Path.cwd()
os.chdir(str(tmpdir))
config = load_config()
os.chdir(str(old))
assert config['local_path'] == tmpdir / '.markdownreveal'
assert config['output_path'] == config['local_path'] / 'out'
assert config['footer'] == 'local footer'
assert config['header'] == 'style header'
assert 'markdownreveal/style-default' in config['style']
评论列表
文章目录