Skip to content

Commit 2bbdfb1

Browse files
authored
test: minor fixes to notebook/script tests (#1862)
1 parent 6475074 commit 2bbdfb1

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

autotest/test_example_scripts.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
from functools import reduce
3-
from os import linesep
43
from pprint import pprint
54

65
import pytest
@@ -35,7 +34,6 @@ def get_example_scripts(exclude=None):
3534
@pytest.mark.parametrize("script", get_example_scripts())
3635
def test_scripts(script):
3736
stdout, stderr, returncode = run_py_script(script, verbose=True)
38-
3937
if returncode != 0:
4038
if "Missing optional dependency" in stderr:
4139
pkg = re.findall("Missing optional dependency '(.*)'", stderr)[0]
@@ -44,13 +42,3 @@ def test_scripts(script):
4442
assert returncode == 0
4543
pprint(stdout)
4644
pprint(stderr)
47-
# allowed_patterns = ["findfont", "warning", "loose", "match_original"]
48-
# assert (
49-
# not stderr
50-
# or
51-
# # trap warnings & non-fatal errors
52-
# all(
53-
# (not line or any(p in line.lower() for p in allowed_patterns))
54-
# for line in stderr.split(linesep)
55-
# )
56-
# )

autotest/test_notebooks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import re
2+
from pathlib import Path
3+
from pprint import pprint
24

35
import pytest
46
from autotest.conftest import get_project_root_path
@@ -11,8 +13,10 @@ def get_notebooks(pattern=None, exclude=None):
1113
nbpaths = [
1214
str(p)
1315
for p in (prjroot / ".docs" / "Notebooks").glob("*.py")
14-
if pattern in p.name
16+
if pattern is None or pattern in p.name
1517
]
18+
19+
# sort for pytest-xdist: workers must collect tests in the same order
1620
return sorted(
1721
[p for p in nbpaths if not exclude or not any(e in p for e in exclude)]
1822
)
@@ -39,3 +43,5 @@ def test_notebooks(notebook):
3943
pytest.skip(f"notebook requires package {pkg!r}")
4044

4145
assert returncode == 0, f"could not run {notebook}"
46+
pprint(stdout)
47+
pprint(stderr)

0 commit comments

Comments
 (0)