Skip to content

Commit 20670e6

Browse files
authored
fix tests for stand-alone example scripts (#3605)
* add test that fails when there are no examples detected * use rglob instead of glob to find example scripts * changelog
1 parent e456b09 commit 20670e6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

changes/3605.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug in the test suite that prevented stand-alone example scripts from being tested.

tests/test_examples.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from packaging.requirements import Requirement
1212

1313
examples_dir = "examples"
14-
script_paths = Path(examples_dir).glob("*.py")
14+
script_paths = tuple(Path(examples_dir).rglob("*.py"))
1515

1616
PEP_723_REGEX: Final = r"(?m)^# /// (?P<type>[a-zA-Z0-9-]+)$\s(?P<content>(^#(| .*)$\s)+)^# ///$"
1717

@@ -62,6 +62,13 @@ def resave_script(source_path: Path, dest_path: Path) -> None:
6262
dest_path.write_text(dest_text)
6363

6464

65+
def test_script_paths() -> None:
66+
"""
67+
Test that our test fixture is working properly and collecting script paths.
68+
"""
69+
assert len(script_paths) > 0
70+
71+
6572
@pytest.mark.skipif(
6673
sys.platform in ("win32",), reason="This test fails due for unknown reasons on Windows in CI."
6774
)

0 commit comments

Comments
 (0)