Use file_regression to generate the files to compare

This shall make the maintenance of data files a little easier in the
future.
This commit is contained in:
Karolina Surma
2021-08-24 13:24:41 +02:00
parent 5de54f32ea
commit 8a94dbf001
12 changed files with 129 additions and 29 deletions
+9 -21
View File
@@ -4,34 +4,22 @@ import pytest
import conf2spec
def get_test_cases():
"""Go through all 'tests/' folders and get their names.
Yield the next folder name."""
def get_config_files():
"""Yield the relative paths to the config files placed in 'tests/test_configs'."""
source_path = Path("tests/")
for path in source_path.glob("pyp2spec_*"):
yield path.name
source_path = Path("tests/test_configs")
for path in source_path.iterdir():
yield path
@pytest.mark.parametrize(
("test_case"),
get_test_cases(),
)
def test_generated_specfile(test_case):
# Get config and expected resulting file
config_file = Path("tests/") / test_case / f"{test_case}.conf"
expected_file = Path("tests/") / test_case / f"{test_case}.spec"
@pytest.mark.parametrize(("config"), get_config_files())
def test_generated_specfile(file_regression, config):
# Run the conf2spec converter
conf = conf2spec.load_configuration(config_file)
conf = conf2spec.load_configuration(config)
rendered_file = conf2spec.write_spec_file(conf)
# Compare the results
with open(rendered_file, "r") as rendered_f:
rendered = rendered_f.read()
with open(expected_file, "r") as expected_f:
expected = expected_f.read()
assert rendered == expected
# Delete rendered file
Path(rendered_file).unlink()
file_regression.check(rendered, basename=config.stem, extension=".spec")
@@ -0,0 +1,68 @@
Name: python-markdown-it-py
Version: 1.1.0
Release: 3%{?dist}
Summary: Python port of markdown-it
License: MIT
URL: https://github.com/executablebooks/markdown-it-py
Source0: %{url}/archive/v%{version}/markdown-it-py-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python3-devel
%global _description %{expand:
Markdown parser done right. Its features:
Follows the CommonMark spec for baseline parsing.
Has configurable syntax: you can add new rules and even replace existing ones.
Pluggable: Adds syntax extensions to extend the parser.
High speed & safe by default
}
BuildRequires: python3-setuptools
BuildRequires: python3-pytest
BuildRequires: python3-pytest-benchmark
BuildRequires: python3-psutil
%description %_description
%package -n python3-markdown-it-py
Summary: %{summary}
%description -n python3-markdown-it-py %_description
%prep
%autosetup -p1 -n markdown-it-py-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%install
%pyproject_install
%pyproject_save_files markdown_it
%check
%pytest -k "not test_pretty and \
not test_table_tokens and \
not test_file and \
not test_use_existing_env and \
not test_store_labels and \
not test_linkify"
%files -n python3-markdown-it-py -f %{pyproject_files}
%doc README.md
%license LICENSE LICENSE.markdown-it
%{_bindir}/markdown-it
%changelog
* Fri Jul 23 2021 Package Maintainer <package@maintainer.com> - 1.1.0-3
- Rebuilt
@@ -1,4 +1,4 @@
name = "click"
pypi_name = "click"
python_name = "python-click"
module_name = "click"
version = "7.1.2"
@@ -1,4 +1,4 @@
name = "jupyter-packaging"
pypi_name = "jupyter-packaging"
python_name = "python-jupyter-packaging"
module_name = "jupyter_packaging"
version = "0.10.4"
@@ -0,0 +1,42 @@
pypi_name = "markdown-it-py"
python_name = "python-markdown-it-py"
module_name = "markdown_it"
version = "1.1.0"
release = "3"
summary = "Python port of markdown-it"
license = "MIT"
url = "https://github.com/executablebooks/markdown-it-py"
source = "%{url}/archive/v%{version}/markdown-it-py-%{version}.tar.gz"
description = '''
Markdown parser done right. Its features:
Follows the CommonMark spec for baseline parsing.
Has configurable syntax: you can add new rules and even replace existing ones.
Pluggable: Adds syntax extensions to extend the parser.
High speed & safe by default
'''
manual_build_requires = [
"python3-setuptools",
"python3-pytest",
"python3-pytest-benchmark",
"python3-psutil"
]
test = "pytest"
unwanted_tests = [
"test_pretty",
"test_table_tokens",
"test_file",
"test_use_existing_env",
"test_store_labels",
"test_linkify",
]
[files]
license_files = ["LICENSE", "LICENSE.markdown-it"]
doc_files = ["README.md"]
binary_files = ["markdown-it"]
[changelog]
changelog_head = "Fri Jul 23 2021 Package Maintainer <package@maintainer.com>"
changelog_msg = "Rebuilt"
@@ -1,4 +1,4 @@
name = "tomli"
pypi_name = "tomli"
python_name = "python-tomli"
module_name = "tomli"
version = "1.1.0"