tests._test_examples   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 0
eloc 19
dl 0
loc 26
rs 10
c 0
b 0
f 0
1
import glob
2
import os
3
import subprocess
4
from subprocess import DEVNULL, STDOUT
5
6
here = os.path.dirname(os.path.abspath(__file__))
7
8
files0 = glob.glob(here + "/../examples/*/*.py")
9
files1 = glob.glob(here + "/../examples/*.py")
10
11
files = files0 + files1
12
13
print("run files:", files)
14
15
for file_path in files:
16
    file_name = str(file_path.rsplit("/", maxsplit=1)[1])
17
18
    try:
19
        print("\033[0;33;40m Testing", file_name, end="...\r")
20
        subprocess.check_call(["python", file_path], stdout=DEVNULL, stderr=STDOUT)  # noqa: S603, S607
21
    except subprocess.CalledProcessError:
22
        print("\033[0;31;40m Error in", file_name)
23
    else:
24
        print("\033[0;32;40m", file_name, "is correct")
25
print("\n")
26