forked from dlubal-software/RFEM_Python_Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExamples.py
30 lines (26 loc) · 989 Bytes
/
Examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import sys
import subprocess
from fnmatch import fnmatch
PROJECT_ROOT = os.path.abspath(os.path.join(
os.path.dirname(__file__),
os.pardir)
)
sys.path.append(PROJECT_ROOT)
root = PROJECT_ROOT+"\\Examples"
pattern = "*.py"
def test_examples():
"""
Run this function in order to execute all *.py files in Examples folder.
This routine is exempt from standard pytest collection because it requires manual input.
When executing in cmd always use verbose (-s) to run scripts without GUI.
Example:
pytest -s ./RFEM_Python_Client/UnitTests/Examples.py
"""
print() # jump 1 line further
for path, subdirs, files in os.walk(root):
for name in files:
if fnmatch(name, pattern) and name != "__init__.py":
example = os.path.join(path, name)
process = subprocess.Popen('python '+example, shell=True) # shell=True has to be there
process.wait()