Refactor tests to use the Selections object instead of the Policy object
[zeroinstall/zeroinstall-mseaborn.git] / tests / testall.py
bloba0ec2c6e92832cbe5f57966319fb0ce289c66cb3
1 #!/usr/bin/env python2.4
2 import unittest, os, sys
4 # Catch silly mistakes...
5 os.environ['HOME'] = '/home/idontexist'
7 try:
8 import coverage
9 coverage.erase()
10 coverage.start()
11 except ImportError:
12 coverage = None
14 my_dir = os.path.dirname(sys.argv[0])
15 if not my_dir:
16 my_dir=os.getcwd()
18 suite_names = [f[:-3] for f in os.listdir(my_dir)
19 if f.startswith('test') and f.endswith('.py')]
20 suite_names.remove('testall')
21 suite_names.sort()
23 alltests = unittest.TestSuite()
25 for name in suite_names:
26 m = __import__(name, globals(), locals(), [])
27 alltests.addTest(m.suite)
29 a = unittest.TextTestRunner().run(alltests)
31 if coverage:
32 coverage.stop()
33 else:
34 print "Coverage module not found. Skipping coverage report."
36 print "\nResult", a
37 if not a.wasSuccessful():
38 sys.exit(1)
40 if coverage:
41 all_sources = []
42 def incl(d):
43 for x in os.listdir(d):
44 if x.endswith('.py'):
45 all_sources.append(os.path.join(d, x))
46 incl('../zeroinstall/injector')
47 incl('../zeroinstall/zerostore')
48 coverage.report(all_sources + ['../0launch'])