From ad2e5d30a33e593450fc59a289bf63e369a112a3 Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Thu, 5 Oct 2023 15:53:33 +0200 Subject: [PATCH] Translate task in conftest.py --- driver/conftest.py | 21 +++++++++++++++++++++ driver/tests.py | 16 ---------------- 2 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 driver/conftest.py diff --git a/driver/conftest.py b/driver/conftest.py new file mode 100644 index 0000000000..1273ea1b83 --- /dev/null +++ b/driver/conftest.py @@ -0,0 +1,21 @@ +# This file is read by pytest before running the tests to set them up. We use it +# to have the SAS+ file for the example task ready for the @pytest.parametrize +# function in tests.py. Translating the task in setup_module() does not work in +# this case, because the @pytest.parametrize decorator is executed before +# setup_module() is called. + +import subprocess +import sys + +from .util import REPO_ROOT_DIR + + +def translate(): + """Create output.sas file for example task.""" + cmd = [sys.executable, "fast-downward.py", "--translate", + "misc/tests/benchmarks/gripper/prob01.pddl"] + subprocess.check_call(cmd, cwd=REPO_ROOT_DIR) + + +def pytest_sessionstart(session): + translate() diff --git a/driver/tests.py b/driver/tests.py index c9f61179d2..7b060dca8b 100644 --- a/driver/tests.py +++ b/driver/tests.py @@ -21,22 +21,6 @@ from .util import REPO_ROOT_DIR, find_domain_filename -def translate(): - """Create translated task.""" - cmd = [sys.executable, "fast-downward.py", "--translate", - "misc/tests/benchmarks/gripper/prob01.pddl"] - subprocess.check_call(cmd, cwd=REPO_ROOT_DIR) - -# We need to translate the example task when this module is imported to have the -# SAS+ file ready for the @pytest.parametrize function below. Translating the -# task in setup_module() does not work here, because the @pytest.parametrize -# decorator is executed before setup_module() is called. An alternative would be -# to use a conftest.py file and call translate() in a pytest_sessionstart() -# function, but that adds another file and leads to dumping the translator -# output to the terminal. -translate() - - def cleanup(): subprocess.check_call([sys.executable, "fast-downward.py", "--cleanup"], cwd=REPO_ROOT_DIR)