From fa23575550817252846d2ff22b910e3514dc5476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Fri, 27 Jun 2025 16:11:44 +0200 Subject: [PATCH] Test generated precice-config with checker --- tests/test_examples.py | 21 +++++++++++++-------- tox.ini | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index b1ff901..8c67237 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -10,16 +10,21 @@ def list_examples(): @pytest.mark.parametrize("example", list_examples()) -def test_application_with_example(example: Path): +def test_application_with_example(tmp_path, example: Path): """Test the application with each example topology files""" assert example.exists() and example.is_file(), "topology file doesn't exist" - with tempfile.TemporaryDirectory() as temp_dir: - cmd = ["precice-case-generate", "-f", str(example), "-o", temp_dir] - print(f"Running {cmd}") - subprocess.run(cmd) + cmd = ["precice-case-generate", "-f", str(example), "-o", str(tmp_path)] + print(f"Running {cmd}") + subprocess.run(cmd, check=True) - output = [p.name for p in Path(temp_dir).iterdir()] - print(f"Output {output}") - assert output, "Nothing generated" + output = list(tmp_path.iterdir()) + print(f"Output {[p.name for p in output]}") + assert output, "Nothing generated" + + config = tmp_path / "precice-config.xml" + + assert config.exists(), "No precice-config.xml generated" + + subprocess.run(["precice-cli", "config", "check", str(config)], check=True) diff --git a/tox.ini b/tox.ini index 784b66e..e7646f8 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ description = run the tests with pytest package = wheel wheel_build_env = .pkg deps = + precice-cli@ git+https://github.com/precice/cli.git pytest>=6 commands = pytest {tty:--color=yes} {posargs}