-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.py
42 lines (33 loc) · 936 Bytes
/
tests.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
# A very light smattering of tests
import inspect
import sys
class Tests:
# Class setup
#############
#!# Tests #!#
#############
# TODO: Define tests here (which start with the word test)
def test_nothing(self):
pass
if __name__ == '__main__':
tests = Tests()
def is_test(method):
return inspect.ismethod(method) and method.__name__.startswith('test')
tests = list(inspect.getmembers(tests, is_test))
tests.sort(key=lambda func: func[1].__code__.co_firstlineno)
for test in tests:
if len(sys.argv) > 1: # Requested specific test(s)
if test[0] not in sys.argv[1:]:
continue
# Test setup (nothing yet)
# Run test
print('---', test[0], 'started')
try:
test[1]()
except Exception:
print('!!!', test[0], 'failed:')
import traceback
traceback.print_exc()
sys.exit(-1)
print('===', test[0], 'passed')
print('\nAll tests passed')