Skip to content

Commit

Permalink
add script to test all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBlanke committed Apr 28, 2024
1 parent 0e0fddb commit a9df628
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ reinstall: uninstall install

reinstall-editable: uninstall install-editable

test-examples:
cd tests; \
python _test_examples.py

tox-test:
tox -- -x -p no:warnings -rfEX tests/ \

py-test:
python -m pytest -x -p no:warnings tests/; \

test: py-test tox-test
test: py-test test-examples

requirement:
cd requirements/; \
Expand Down
24 changes: 24 additions & 0 deletions tests/_test_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os, sys, glob
import subprocess
from subprocess import DEVNULL, STDOUT

here = os.path.dirname(os.path.abspath(__file__))

files0 = glob.glob(here+"/../examples/*/*.py")
files1 = glob.glob(here+"/../examples/*.py")

files = files0 + files1

print("run files:", files)

for file_path in files:
file_name = str(file_path.rsplit("/", maxsplit=1)[1])

try:
print("\033[0;33;40m Testing", file_name, end="...\r")
subprocess.check_call(["python", file_path], stdout=DEVNULL, stderr=STDOUT)
except subprocess.CalledProcessError:
print("\033[0;31;40m Error in", file_name)
else:
print("\033[0;32;40m", file_name, "is correct")
print("\n")

0 comments on commit a9df628

Please sign in to comment.