-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
37 lines (28 loc) · 655 Bytes
/
test.py
File metadata and controls
37 lines (28 loc) · 655 Bytes
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
#pytest
def func(x):
return x + 1
def test_func():
assert func(3) == 5
def run_tests():
results = {
"pass": 0,
"fail": 0,
"error": 0
}
for (name, test) in globals().items():
if not name.startswith("test_"):
continue
try:
test()
results["pass"] +=1
except AssertionError:
results["fail"] +=1
except Exception:
results["error"] +=1
print(f"pass {results['pass']}")
print(f'fail {results['fail']}')
print(f'error {results['error']}')
def main():
run_tests()
if __name__ == "__main__":
main()