xboa
XBOATest.py
Go to the documentation of this file.
1 import os
2 try:
3  import coverage
4  my_coverage = coverage.coverage(source=['xboa.Hit', 'xboa.Bunch', 'xboa.Common'])
5  my_coverage.start()
6 except Exception:
7  my_coverage = None
8 
9 import StringIO
10 import sys
11 import time
12 import math
13 import string
14 try:
15  import numpy
16  from numpy import linalg
17 except ImportError:
18  pass
19 import operator
20 import bisect
21 
23 import xboa.test.HitTest
26 
27 import xboa.Common as Common
28 import xboa.Hit
29 import xboa.Bunch
30 
31 
32 """
33 Test script:
34 One test function for each app function; one test function for each module. Name of each function test is blah_test(...)
35 Helper functions are private.
36 Return value 'fail'; 'warning'; 'pass'
37 Module test function is called test_module
38 All tests are called by test_all
39 So:
40  to run all tests call test_all()
41 """
42 __float_tol = Common.float_tolerance
43 
44 def main():
45  results = test_all()
46  print '\n================\n|| XBOA TESTS ||\n================'
47  print 'Passed ',results[0],' tests\nFailed ',results[1],' tests\n',results[2],' warnings\n\n\n'
48  return
49 
50 def test_all():
51  (common_p, common_f, common_w) = xboa.test.CommonTest.test_common()
52  (hit_p, hit_f, hit_w) = xboa.test.HitTest.test_hit()
53  (bunch_p, bunch_f, bunch_w) = xboa.test.BunchTest.test_bunch()
54  (system_p, system_f, system_w) = xboa.test.SystemTest.test_system()
55  return (common_p+hit_p+bunch_p+system_p, common_f+hit_f+bunch_f+system_f, common_w+hit_w+bunch_w+system_w)
56 
57 if __name__ == '__main__':
58  main()
59  if my_coverage != None:
60  try:
61  my_coverage.stop()
62  my_coverage.html_report()
63  except Exception:
64  pass