1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """Finish running tests and print statistics.
18 """
19
20 import sys
21
22 from time import time
23
24 from pypower.t.t_globals import TestGlobals
25
26
28 """Finish running tests and print statistics.
29
30 Checks the global counters that were updated by calls to C{t_ok}
31 and C{t_is} and prints out a summary of the test results.
32
33 @author: Ray Zimmerman (PSERC Cornell)
34 @author: Richard Lincoln
35 """
36 TestGlobals.t_counter -= 1
37
38 if (TestGlobals.t_counter == TestGlobals.t_num_of_tests) and \
39 (TestGlobals.t_counter == TestGlobals.t_ok_cnt + TestGlobals.t_skip_cnt) and \
40 (TestGlobals.t_not_ok_cnt == 0):
41 all_ok = True
42 else:
43 all_ok = False
44
45 s = ''
46 if TestGlobals.t_quiet:
47 if all_ok:
48 s += 'ok'
49 if TestGlobals.t_skip_cnt:
50 s += ' (%d of %d skipped)' % \
51 (TestGlobals.t_skip_cnt, TestGlobals.t_num_of_tests)
52 else:
53 s += 'not ok\n'
54 s += '\t##### Ran %d of %d tests: %d passed, %d failed' % \
55 (TestGlobals.t_counter, TestGlobals.t_num_of_tests,
56 TestGlobals.t_ok_cnt, TestGlobals.t_not_ok_cnt)
57 if TestGlobals.t_skip_cnt:
58 s += ', %d skipped' % TestGlobals.t_skip_cnt
59 s += '\n'
60 else:
61 if all_ok:
62 if TestGlobals.t_skip_cnt:
63 s += 'All tests successful (%d passed, %d skipped of %d)' % \
64 (TestGlobals.t_ok_cnt, TestGlobals.t_skip_cnt,
65 TestGlobals.t_num_of_tests)
66 else:
67 s += 'All tests successful (%d of %d)' % \
68 (TestGlobals.t_ok_cnt, TestGlobals.t_num_of_tests)
69 else:
70 s += 'Ran %d of %d tests: %d passed, %d failed' % \
71 (TestGlobals.t_counter, TestGlobals.t_num_of_tests,
72 TestGlobals.t_ok_cnt, TestGlobals.t_not_ok_cnt)
73 if TestGlobals.t_skip_cnt:
74 s += ', %d skipped' % TestGlobals.t_skip_cnt
75 s += '\nElapsed time %.2f seconds.\n' % (time() - TestGlobals.t_clock)
76
77 sys.stdout.write(s)
78