~ubuntu-branches/ubuntu/karmic/zeroinstall-injector/karmic

« back to all changes in this revision

Viewing changes to tests/testall.py

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Leonard
  • Date: 2007-01-23 21:50:46 UTC
  • Revision ID: james.westby@ubuntu.com-20070123215046-3ya2x81i99m5ya8r
Tags: upstream-0.25
ImportĀ upstreamĀ versionĀ 0.25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python2.3
 
2
import unittest, os, sys
 
3
try:
 
4
        import coverage
 
5
        coverage.erase()
 
6
        coverage.start()
 
7
except ImportError:
 
8
        coverage = None
 
9
 
 
10
my_dir = os.path.dirname(sys.argv[0])
 
11
if not my_dir:
 
12
        my_dir=os.getcwd()
 
13
 
 
14
sys.argv.append('-v')
 
15
 
 
16
suite_names = [f[:-3] for f in os.listdir(my_dir)
 
17
                if f.startswith('test') and f.endswith('.py')]
 
18
suite_names.remove('testall')
 
19
suite_names.sort()
 
20
 
 
21
alltests = unittest.TestSuite()
 
22
 
 
23
for name in suite_names:
 
24
        m = __import__(name, globals(), locals(), [])
 
25
        alltests.addTest(m.suite)
 
26
 
 
27
a = unittest.TextTestRunner(verbosity=2).run(alltests)
 
28
 
 
29
if coverage:
 
30
        coverage.stop()
 
31
else:
 
32
        print "Coverage module not found. Skipping coverage report."
 
33
 
 
34
print "\nResult", a
 
35
if not a.wasSuccessful():
 
36
        sys.exit(1)
 
37
 
 
38
if coverage:
 
39
        all_sources = []
 
40
        def incl(d):
 
41
                for x in os.listdir(d):
 
42
                        if x.endswith('.py'):
 
43
                                all_sources.append(os.path.join(d, x))
 
44
        incl('../zeroinstall/injector')
 
45
        incl('../zeroinstall/zerostore')
 
46
        coverage.report(all_sources + ['../0launch'])