Skip to content

Commit 6bf7e77

Browse files
authored
Merge pull request #669 from bashtage/maint-pytest
MAINT: Improve pytest skip
2 parents cdbef7a + c0326b0 commit 6bf7e77

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

arch/tests/test_examples.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
SKIP = True
8+
REASON = "Required packages not available"
89

910
try:
1011
import jupyter_client
@@ -34,7 +35,7 @@
3435
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
3536

3637
except ImportError: # pragma: no cover
37-
pytestmark = pytest.mark.skip(reason="Required packages not available")
38+
pytestmark = pytest.mark.skip(reason=REASON)
3839

3940
SLOW_NOTEBOOKS = ["multiple-comparison_examples.ipynb"]
4041
if bool(os.environ.get("ARCH_TEST_SLOW_NOTEBOOKS", False)): # pragma: no cover
@@ -47,16 +48,13 @@
4748
nbs = sorted(glob.glob(os.path.join(NOTEBOOK_DIR, "*.ipynb")))
4849
ids = [os.path.split(nb)[-1].split(".")[0] for nb in nbs]
4950
if not nbs: # pragma: no cover
50-
pytest.mark.skip(reason="No notebooks found and so no tests run")
51-
52-
53-
@pytest.fixture(params=nbs, ids=ids)
54-
def notebook(request):
55-
return request.param
51+
REASON = "No notebooks found and so no tests run"
52+
pytestmark = pytest.mark.skip(reason=REASON)
5653

5754

5855
@pytest.mark.slow
59-
@pytest.mark.skipif(SKIP, reason="Required packages not available")
56+
@pytest.mark.parametrize("notebook", nbs, ids=ids)
57+
@pytest.mark.skipif(SKIP, reason=REASON)
6058
def test_notebook(notebook):
6159
nb_name = os.path.split(notebook)[-1]
6260
if nb_name in SLOW_NOTEBOOKS:

0 commit comments

Comments
 (0)