Skip to content

Commit

Permalink
Translate task in conftest.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp committed Oct 5, 2023
1 parent 1f636f7 commit ad2e5d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
21 changes: 21 additions & 0 deletions driver/conftest.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 0 additions & 16 deletions driver/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ad2e5d3

Please sign in to comment.