-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun_coveralls.py
35 lines (29 loc) · 919 Bytes
/
run_coveralls.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
#!/bin/env/python
import os
try:
from contextlib import suppress
except ImportError:
from contextlib import contextmanager
@contextmanager
def suppress(*exceptions):
try:
yield
except exceptions:
pass
from distutils.sysconfig import get_python_lib
from subprocess import call
if __name__ == '__main__':
# chdir to the site-packages directory so the report lists relative paths
dot_coverage_path = os.path.join(os.getcwd(), '.coverage')
os.chdir(get_python_lib())
with suppress(OSError):
os.remove('.coverage')
os.symlink(dot_coverage_path, '.coverage')
# create a report from the coverage data
if 'TRAVIS' in os.environ:
rc = call('coveralls')
# don't fail test if coveralls submission failed
raise SystemExit(None)
else:
rc = call(['coverage', 'report'])
raise SystemExit(rc)