Run unit-tests in C locale
[zeroinstall/solver.git] / tests / testall.py
blob36496e6d27e420a48206d88cfa6f79ae1450d2f7
1 #!/usr/bin/env python
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 test = unittest.defaultTestLoader.loadTestsFromModule(m)
30 alltests.addTest(test)
32 a = unittest.TextTestRunner(verbosity=2).run(alltests)
34 if coverage:
35 coverage.stop()
36 else:
37 print "Coverage module not found. Skipping coverage report."
39 print "\nResult", a
40 if not a.wasSuccessful():
41 sys.exit(1)
43 if coverage:
44 all_sources = []
45 def incl(d):
46 for x in os.listdir(d):
47 if x.endswith('.py'):
48 all_sources.append(os.path.join(d, x))
49 incl('../zeroinstall/injector')
50 incl('../zeroinstall/zerostore')
51 coverage.report(all_sources + ['../0launch'])