Skip to content

Commit ba47bb8

Browse files
committed
Support running testing subset without pygrackle install
Prior to this PR, our test suite would fail unless we had an editable install. In reality, all test-cases outside of test_models infer the location of the data files based on the location of the test-files, which are never part of the wheel.[^1] Therefore, this PR introduces a few small tweaks to support testing all test-cases outside of test_models. Overall, this will be really useful for providing a more rigorous check of the correctness of our precompiled wheels (see PR grackle-project#320). [^1]: I know that some packages do ship their test-suites as part of the wheel, but that currently makes absolutely no sense for us unless we provide users with an easy way to get the datafiles. We can always revisit this choice in the future after we merge PRs grackle-project#235 & grackle-project#237 (or come up with an equivalent)
1 parent 8a6b1bc commit ba47bb8

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/python/pygrackle/utilities/model_tests.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import os
1616

1717
from pygrackle import chemistry_data
18-
from pygrackle.utilities.data_path import grackle_data_dir
1918

2019
model_test_format_version = 1
2120

@@ -141,6 +140,10 @@ def get_model_set(model_name, parameter_index, input_index):
141140
of the Python example scripts.
142141
"""
143142

143+
# we import this here, rather than at global scope to let us import the
144+
# module when we don't have an editable install (for testing purposes)
145+
from pygrackle.utilities.data_path import grackle_data_dir
146+
144147
if model_name not in model_sets:
145148
raise ValueError("Unkown model name: {model_name}.")
146149

src/python/tests/test_models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55

66
from numpy.testing import assert_allclose
77

8+
from pygrackle.__config__ import _is_editable_installation
89
from pygrackle.utilities.model_tests import model_sets
910
from pygrackle.utilities.testing import run_command
1011

1112
from testing_common import grackle_python_dir
1213

14+
pytestmark = pytest.mark.skipif(
15+
not _is_editable_installation(),
16+
reason="this module currently requires an editable installation"
17+
)
18+
1319
python_example_dir = os.path.join(grackle_python_dir, "examples")
1420

1521
# collect all of the python-examples and various model configurations into

src/python/tests/testing_common.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@
1414

1515
import os
1616

17-
from pygrackle.__config__ import _is_editable_installation
1817
from pygrackle.utilities.misc import dirname
1918

20-
if _is_editable_installation():
21-
grackle_install_dir = dirname(os.path.abspath(__file__), level=4)
22-
grackle_data_dir = os.path.join(grackle_install_dir, "input")
23-
grackle_python_dir = os.path.join(grackle_install_dir, "src", "python")
24-
else:
25-
raise RuntimeError(
26-
"the current version of pygrackle is not an editable installation. No "
27-
"tests that must import from {__file__} can be run"
28-
)
19+
grackle_install_dir = dirname(os.path.abspath(__file__), level=4)
20+
grackle_data_dir = os.path.join(grackle_install_dir, "input")
21+
grackle_python_dir = os.path.join(grackle_install_dir, "src", "python")

0 commit comments

Comments
 (0)