-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_integral.py
executable file
·44 lines (38 loc) · 1.19 KB
/
test_integral.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import importlib
import subprocess
import timeit
from examples import integral
def test_integral():
expected = integral.integrate_f(0, 2, 5000)
result = ()
file = 'output/temp.pyx'
# Compile .pyx program
process = subprocess.Popen(['Cythonize', '-i', file],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
temp = importlib.import_module("output.temp")
if stderr and process.returncode:
# compilation_fails += 1
# print(file + ": Compilation Failed")
print("compilation_fail")
else:
try:
start = timeit.default_timer()
output = temp.integrate_f(0, 2, 5000)
end = timeit.default_timer()
except Exception as e:
# print(e)
# print(file + ": Bug Found")
print("bug_found")
else:
t = end - start
if output == expected:
print(float(t))
else:
# wrong += 1
# print(file + ": Wrong Value")
print("wrong_value")
return
if __name__ == "__main__":
test_integral()