-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests_install.py
34 lines (29 loc) · 1.06 KB
/
tests_install.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
#!/usr/bin/env python
# coding: utf-8
import sys
from pathlib import Path
import unittest
import matplotlib
from climada.util.config import SOURCE_DIR
def find_install_tests():
"""select unit tests."""
suite = unittest.TestLoader().discover(start_dir='climada.engine.test',
pattern='test_cost_benefit.py')
suite.addTest(unittest.TestLoader().discover(start_dir='climada.engine.test',
pattern='test_impact.py'))
return suite
def main():
"""parse input argument: None or 'report'. Execute accordingly."""
if sys.argv[1:]:
import xmlrunner
arg = sys.argv[1]
if arg == 'report':
output = Path(__file__).parent.joinpath('tests_xml')
xmlrunner.XMLTestRunner(output=str(output)).run(find_install_tests())
else:
# execute without xml reports
unittest.TextTestRunner(verbosity=2).run(find_install_tests())
if __name__ == '__main__':
matplotlib.use("Agg")
sys.path.append(str(SOURCE_DIR))
main()