Skip to content

Commit

Permalink
ci: Only test "doc-runnable" examples (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman authored Nov 24, 2023
1 parent 479d5e8 commit 4a967e2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@
EXAMPLE_DIR = HERE.parent / "examples"
example_files = EXAMPLE_DIR.rglob("*.py")


def is_runnable(example: Path) -> bool:
with example.open() as f:
# If `doc-runnable` is not in the first 10 lines,
# we don't consider it testable.
for _ in range(10):
line = next(f)
if "doc-runnable" in line.lower():
return True
return False


parameters = [
pytest.param(example, id=str(example.relative_to(EXAMPLE_DIR)))
for example in example_files
if is_runnable(example)
]


Expand Down

0 comments on commit 4a967e2

Please sign in to comment.