Files
pyp2spec/tests/test_conf2spec.py
T

32 lines
839 B
Python

from pathlib import Path
import pytest
import conf2spec
import config
def get_config_files():
"""Yield the relative paths to the config files placed in 'tests/test_configs'."""
source_path = Path("tests/test_configs")
for path in source_path.iterdir():
yield path
@pytest.mark.parametrize(("config_file"), get_config_files())
def test_generated_specfile(file_regression, config_file):
# Run the conf2spec converter
conf = config.ConfigFile(config_file)
rendered_file = conf2spec.write_spec_file(conf)
# Compare the results
with open(rendered_file, "r") as rendered_f:
rendered = rendered_f.read()
file_regression.check(
rendered,
fullpath=f"tests/expected_specfiles/{rendered_file}",
)
# Cleanup - remove created file
Path.unlink(Path(rendered_file))