Skip to content
Snippets Groups Projects
Commit 1f946b87 authored by u214892's avatar u214892
Browse files

run examples from python instead of shell

parent 61aedfff
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,8 @@ tests: ...@@ -26,7 +26,8 @@ tests:
- apt update - apt update
- apt install -y libgl1-mesa-glx xvfb graphviz xdg-utils libcairo2-dev libjpeg-dev libgif-dev - apt install -y libgl1-mesa-glx xvfb graphviz xdg-utils libcairo2-dev libjpeg-dev libgif-dev
- pip install tox - pip install tox
- xvfb-run tox -e benchmarks,profiling -v --recreate - xvfb-run tox -v -e examples -v --recreate
- xvfb-run tox -v -e benchmarks,profiling -v --recreate
- xvfb-run tox -v --recreate - xvfb-run tox -v --recreate
build_and_deploy_docs: build_and_deploy_docs:
......
import runpy
import sys
from io import StringIO
import importlib_resources
import pkg_resources
from importlib_resources import path
from benchmarks.benchmark_utils import swap_attr
for entry in [entry for entry in importlib_resources.contents('examples') if
not pkg_resources.resource_isdir('examples', entry)
and entry.endswith(".py")
and '__init__' not in entry
and 'demo.py' not in entry
]:
with path('examples', entry) as file_in:
print("*****************************************************************")
print("Running {}".format(entry))
print("*****************************************************************")
with swap_attr(sys, "stdin", StringIO("q")):
runpy.run_path(file_in, run_name="__main__")
...@@ -97,7 +97,7 @@ commands = ...@@ -97,7 +97,7 @@ commands =
; run examples from subfolder to ensure that resources are accessed via resources and not via relative paths ; run examples from subfolder to ensure that resources are accessed via resources and not via relative paths
sh -c 'mkdir -p {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5' sh -c 'mkdir -p {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5'
; pipe echo into python since some examples expect input to close the window after the example is run ; pipe echo into python since some examples expect input to close the window after the example is run
sh -c 'cd {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5 && ls {toxinidir}/examples/*.py | xargs -I{} -n 1 sh -c "echo -e \"\n====== Running {} ========\n\"; echo "q" | python {}"' sh -c 'cd {envtmpdir}/c236d3c240d61a0969d4cb59e2180ce5 && python {toxinidir}/benchmarks/run_all_examples.py'
[testenv:notebooks] [testenv:notebooks]
basepython = python basepython = python
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment