Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Sep 12, 2024
1 parent e5d9b4e commit 080ad2b
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions ixmp/tests/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,33 @@
FLAKY = pytest.mark.flaky(
reruns=5,
rerun_delay=2,
condition="GITHUB_ACTIONS" in os.environ and platform.system() == "Windows",
condition=GHA and platform.system() == "Windows",
reason="Flaky; see iiasa/ixmp#543",
)


@pytest.fixture(scope="session")
def default_args():
"""Default arguments for :func:`.run_notebook."""
if GHA:
# Use a longer timeout
return dict(timeout=30)
else:
return dict()
# Use a longer timeout for GHA
return dict(timeout=30) if GHA else dict()


@FLAKY
@pytest.mark.xdist_group(name=f"{group_base_name}-0")
def test_py_transport(tutorial_path, tmp_path, tmp_env):
def test_py_transport(tutorial_path, tmp_path, tmp_env, default_args):
fname = tutorial_path / "transport" / "py_transport.ipynb"
args = default_args()
nb, errors = run_notebook(fname, tmp_path, tmp_env, **args)
nb, errors = run_notebook(fname, tmp_path, tmp_env, **default_args)
assert errors == []

# FIXME use get_cell_by_name instead of assuming cell count/order is fixed
assert np.isclose(get_cell_output(nb, -5)["lvl"], 153.6750030517578)


@pytest.mark.xdist_group(name=f"{group_base_name}-0")
def test_py_transport_scenario(tutorial_path, tmp_path, tmp_env):
def test_py_transport_scenario(tutorial_path, tmp_path, tmp_env, default_args):
fname = tutorial_path / "transport" / "py_transport_scenario.ipynb"
args = default_args()
nb, errors = run_notebook(fname, tmp_path, tmp_env, **args)
nb, errors = run_notebook(fname, tmp_path, tmp_env, **default_args)
assert errors == []

assert np.isclose(get_cell_output(nb, "scen-z")["lvl"], 153.675)
Expand All @@ -56,24 +52,22 @@ def test_py_transport_scenario(tutorial_path, tmp_path, tmp_env):
@pytest.mark.xdist_group(name=f"{group_base_name}-1")
@pytest.mark.rixmp
# TODO investigate and resolve the cause of the time outs; remove this mark
@pytest.mark.skipif(
"GITHUB_ACTIONS" in os.environ and sys.platform == "linux", reason="Times out"
)
def test_R_transport(tutorial_path, tmp_path, tmp_env):
@pytest.mark.skipif(GHA and sys.platform == "linux", reason="Times out")
def test_R_transport(tutorial_path, tmp_path, tmp_env, default_args):
fname = tutorial_path / "transport" / "R_transport.ipynb"
args = default_args()
nb, errors = run_notebook(fname, tmp_path, tmp_env, kernel_name="IR", **args)
nb, errors = run_notebook(
fname, tmp_path, tmp_env, kernel_name="IR", **default_args
)
assert errors == []


@pytest.mark.xdist_group(name=f"{group_base_name}-1")
@pytest.mark.rixmp
# TODO investigate and resolve the cause of the time outs; remove this mark
@pytest.mark.skipif(
"GITHUB_ACTIONS" in os.environ and sys.platform == "linux", reason="Times out"
)
def test_R_transport_scenario(tutorial_path, tmp_path, tmp_env):
@pytest.mark.skipif(GHA and sys.platform == "linux", reason="Times out")
def test_R_transport_scenario(tutorial_path, tmp_path, tmp_env, default_args):
fname = tutorial_path / "transport" / "R_transport_scenario.ipynb"
args = default_args()
nb, errors = run_notebook(fname, tmp_path, tmp_env, kernel_name="IR", **args)
nb, errors = run_notebook(
fname, tmp_path, tmp_env, kernel_name="IR", **default_args
)
assert errors == []

0 comments on commit 080ad2b

Please sign in to comment.