tests._test_examples   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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