Skip to content

Commit

Permalink
Merge pull request #669 from bashtage/maint-pytest
Browse files Browse the repository at this point in the history
MAINT: Improve pytest skip
  • Loading branch information
bashtage authored Jun 27, 2023
2 parents cdbef7a + c0326b0 commit 6bf7e77
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions arch/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

SKIP = True
REASON = "Required packages not available"

try:
import jupyter_client
Expand Down Expand Up @@ -34,7 +35,7 @@
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())

except ImportError: # pragma: no cover
pytestmark = pytest.mark.skip(reason="Required packages not available")
pytestmark = pytest.mark.skip(reason=REASON)

SLOW_NOTEBOOKS = ["multiple-comparison_examples.ipynb"]
if bool(os.environ.get("ARCH_TEST_SLOW_NOTEBOOKS", False)): # pragma: no cover
Expand All @@ -47,16 +48,13 @@
nbs = sorted(glob.glob(os.path.join(NOTEBOOK_DIR, "*.ipynb")))
ids = [os.path.split(nb)[-1].split(".")[0] for nb in nbs]
if not nbs: # pragma: no cover
pytest.mark.skip(reason="No notebooks found and so no tests run")


@pytest.fixture(params=nbs, ids=ids)
def notebook(request):
return request.param
REASON = "No notebooks found and so no tests run"
pytestmark = pytest.mark.skip(reason=REASON)


@pytest.mark.slow
@pytest.mark.skipif(SKIP, reason="Required packages not available")
@pytest.mark.parametrize("notebook", nbs, ids=ids)
@pytest.mark.skipif(SKIP, reason=REASON)
def test_notebook(notebook):
nb_name = os.path.split(notebook)[-1]
if nb_name in SLOW_NOTEBOOKS:
Expand Down

0 comments on commit 6bf7e77

Please sign in to comment.