forked from seatme/nucleon.amqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
43 lines (32 loc) · 1016 Bytes
/
runtests.py
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
40
41
42
#!/usr/bin/python
import os
import sys
import nose
from coverage import coverage
import nucleon
thisdir = os.path.abspath(os.path.dirname(__file__))
#Start collecting coverage data
cov = coverage(branch=True, source=[os.path.join(thisdir, 'nucleon', 'amqp')])
cov.start()
# Run the nosetest with xunit enabled
args = (
'nosetests -v -s --nologcapture '
'--with-xunit --xunit-file tests.xunit.xml tests'
).split()
nose.run(argv=args)
#Stop collecting the coverage data and convert it into XML format
cov.stop()
cov.save()
cov.xml_report(outfile='coverage.xml.in')
# Rewrite coverage report to remove absolute paths
subs = [] # substitutions we want to make
for p in nucleon.__path__:
subs.append(os.path.dirname(p) + '/')
subs.append(p.replace('/', '.'))
with open('coverage.xml.in', 'r') as input:
with open('coverage.xml', 'w') as output:
for l in input:
for s in subs:
l = l.replace(s, '')
output.write(l)
cov.report(file=sys.stdout)