2 import unittest
, os
, sys
, tempfile
, shutil
, atexit
4 my_dir
= os
.path
.abspath(os
.path
.dirname(sys
.argv
[0]))
6 coverdir
= tempfile
.mkdtemp(prefix
='0compile-coverage-')
7 atexit
.register(shutil
.rmtree
, coverdir
)
9 os
.environ
["COVERAGE_FILE"] = os
.path
.join(coverdir
, 'coverage')
16 print "Coverage module not found. Skipping coverage report."
20 suite_names
= [f
[:-3] for f
in os
.listdir(my_dir
)
21 if f
.startswith('test') and f
.endswith('.py')]
24 alltests
= unittest
.TestSuite()
26 for name
in suite_names
:
27 m
= __import__(name
, globals(), locals(), [])
28 alltests
.addTest(m
.suite
)
30 a
= unittest
.TextTestRunner(verbosity
=2).run(alltests
)
33 if not a
.wasSuccessful():
37 coverage
.the_coverage
.collect()
40 for x
in os
.listdir(d
):
42 all_sources
.append(os
.path
.join(d
, x
))
43 incl(os
.path
.join(my_dir
, '..'))
44 coverage
.report(all_sources
)