Skip to content

Commit e74eb94

Browse files
committed
tests: Run examples as part of test suite
The example code under examples/ also function as valuable tests. This adds a tests/test_examples.py file that runs each example script under examples/ as a separate test case. For the examples, we simply consider a zero exit code to signal that the examples completed successfully. A non-zero exit causes a test failure.
1 parent cc78f85 commit e74eb94

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_examples.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from pathlib import Path
2+
import pytest
3+
import subprocess
4+
5+
example_scripts = (Path(__file__).parent.parent / "examples").glob("*.py")
6+
7+
8+
@pytest.mark.parametrize("script", example_scripts)
9+
def test_example_script(script):
10+
subprocess.run([script], check=True)

0 commit comments

Comments
 (0)