Better exception handling in GUI.
[zeroinstall/zeroinstall-rsl.git] / tests / testall.py
blob1a1b5a641de1d13cac091a12cbd1eff556cfc437
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 sys.argv.append('-v')
20 suite_names = [f[:-3] for f in os.listdir(my_dir)
21 if f.startswith('test') and f.endswith('.py')]
22 suite_names.remove('testall')
23 suite_names.sort()
25 alltests = unittest.TestSuite()
27 for name in suite_names:
28 m = __import__(name, globals(), locals(), [])
29 alltests.addTest(m.suite)
31 a = unittest.TextTestRunner(verbosity=2).run(alltests)
33 if coverage:
34 coverage.stop()
35 else:
36 print "Coverage module not found. Skipping coverage report."
38 print "\nResult", a
39 if not a.wasSuccessful():
40 sys.exit(1)
42 if coverage:
43 all_sources = []
44 def incl(d):
45 for x in os.listdir(d):
46 if x.endswith('.py'):
47 all_sources.append(os.path.join(d, x))
48 incl('../zeroinstall/injector')
49 incl('../zeroinstall/zerostore')
50 coverage.report(all_sources + ['../0launch'])