Coverage for gpkit/tests/run_tests.py: 100%

31 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-01-07 22:56 -0500

1"""Script for running all gpkit unit tests""" 

2from gpkit.tests.helpers import run_tests 

3#pylint: disable=import-outside-toplevel 

4 

5 

6def import_tests(): 

7 """Get a list of all GPkit unit test TestCases""" 

8 tests = [] 

9 

10 from gpkit.tests import t_tools 

11 tests += t_tools.TESTS 

12 

13 from gpkit.tests import t_sub 

14 tests += t_sub.TESTS 

15 

16 from gpkit.tests import t_vars 

17 tests += t_vars.TESTS 

18 

19 from gpkit.tests import t_nomials 

20 tests += t_nomials.TESTS 

21 

22 from gpkit.tests import t_constraints 

23 tests += t_constraints.TESTS 

24 

25 from gpkit.tests import t_nomial_array 

26 tests += t_nomial_array.TESTS 

27 

28 from gpkit.tests import t_model 

29 tests += t_model.TESTS 

30 

31 from gpkit.tests import t_solution_array 

32 tests += t_solution_array.TESTS 

33 

34 from gpkit.tests import t_small 

35 tests += t_small.TESTS 

36 

37 from gpkit.tests import t_examples 

38 tests += t_examples.TESTS 

39 

40 from gpkit.tests import t_keydict 

41 tests += t_keydict.TESTS 

42 

43 return tests 

44 

45 

46def run(xmloutput=False, tests=None, verbosity=1): 

47 """Run all gpkit unit tests. 

48 

49 Arguments 

50 --------- 

51 xmloutput: bool 

52 If true, generate xml output files for continuous integration 

53 """ 

54 if tests is None: 

55 tests = import_tests() 

56 if xmloutput: 

57 run_tests(tests, xmloutput='test_reports') 

58 else: # pragma: no cover 

59 run_tests(tests, verbosity=verbosity) 

60 

61if __name__ == "__main__": # pragma: no cover 

62 run()