blob: 0ab0e2ff2978512e761dcd3a72140a2a965b3a24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# Coverage-test Coverage itself.
import coverage
import os, shutil, sys
HTML_DIR = "htmlcov"
if os.path.exists(HTML_DIR):
shutil.rmtree(HTML_DIR)
cov = coverage.coverage()
cov.erase()
cov.start()
# Re-import coverage to get it coverage tested! I don't understand all the
# mechanics here, but if I don't carry over the imported modules (in covmods),
# then things go haywire (os == None eventually).
covmods = {}
covdir = os.path.split(coverage.__file__)
for name, mod in sys.modules.items():
if name.startswith('coverage'):
if hasattr(mod, '__file__') and mod.__file__.startswith(covdir):
covmods[name] = mod
del sys.modules[name]
import coverage # don't warn about re-import: pylint: disable-msg=W0404
sys.modules.update(covmods)
# Run nosetests, with the arguments from our command line.
import nose
nose.run(sys.argv[1:])
cov.stop()
cov.clear_exclude()
cov.exclude("#pragma: no cover")
cov.exclude("def __repr__")
cov.exclude("if __name__ == .__main__.:")
cov.html_report(directory=HTML_DIR, ignore_errors=True)
|