-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
64 lines (46 loc) · 1.27 KB
/
test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
# noqa
# pylint: skip-file
import sys
import unittest
import subprocess
import coverage
def suite():
"""test suite"""
test_loader = unittest.TestLoader()
test_suite = test_loader.discover("e2fyi", pattern="*_test.py")
return test_suite
def run_unittest():
cov = coverage.Coverage()
cov.start()
print("unittest:")
result = unittest.TextTestRunner(verbosity=2).run(suite())
cov.stop()
cov.save()
print("coverage report:")
cov.report()
return result.wasSuccessful()
def run_pylint():
print("checking with pylint:")
return (
subprocess.call(["pylint", "e2fyi"], stdout=sys.stdout, stderr=sys.stderr) == 0
)
def run_mypy():
print("checking with mypy:")
return subprocess.call(["mypy", "e2fyi"], stdout=sys.stdout, stderr=sys.stderr) == 0
def run_black():
print("checking with black:")
return (
subprocess.call(
["black", "--check", "e2fyi"], stdout=sys.stdout, stderr=sys.stderr
)
== 0
)
def main():
tests = [run_pylint, run_black, run_mypy, run_unittest]
is_successful = True
for test in tests:
is_successful = is_successful and test()
return 0 if is_successful else 1
if __name__ == "__main__":
exit(main())