-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/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') | ||
raise SystemExit(rc) | ||
else: | ||
rc = call(['coverage', 'report']) | ||
raise SystemExit(rc) |