This repository has been archived by the owner on Jul 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix documentation reg. unittest, add run_tests.py
There is a problem with running nosetest - the previous html coverage reports are not properly removed thus subsequent runs of nosetest --with-coverage... result in "File exists error". The old run_tests.py file was restored and put into the main directory. It takes care of removing old html reports and running the tests.
- Loading branch information
Vespian
committed
Mar 9, 2014
1 parent
47e80bc
commit 957d555
Showing
4 changed files
with
107 additions
and
9 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,26 @@ | ||
# .coveragerc to control coverage.py | ||
[run] | ||
branch = True | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain about missing debug-only code: | ||
def __repr__ | ||
if self\.debug | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
||
# Don't complain if non-runnable code isn't run: | ||
if 0: | ||
if __name__ == .__main__.: | ||
source = | ||
./certcheck/ | ||
|
||
|
||
[html] | ||
directory = test/output_coverage_html | ||
|
||
[paths] |
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
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,48 @@ | ||
#!/usr/bin/python -tt | ||
|
||
#Make it a bit more like python3: | ||
from __future__ import absolute_import | ||
from __future__ import print_function | ||
|
||
import coverage | ||
import os | ||
import shutil | ||
import sys | ||
import unittest | ||
|
||
|
||
def main(): | ||
major, minor, micro, releaselevel, serial = sys.version_info | ||
|
||
if major == 2 and minor < 7: | ||
print("In order to run tests you need at least Python 2.7") | ||
sys.exit(1) | ||
|
||
if major == 3: | ||
print("Tests were not tested on Python 3.X, use at your own risk") | ||
sys.exit(1) | ||
|
||
#Cleanup old html report: | ||
for root, dirs, files in os.walk('test/output_coverage_html/'): | ||
for f in files: | ||
if f == '.gitignore' or f == '.empty_dir': | ||
continue | ||
os.unlink(os.path.join(root, f)) | ||
for d in dirs: | ||
shutil.rmtree(os.path.join(root, d)) | ||
|
||
#Perform coverage analisys: | ||
cov = coverage.coverage() | ||
|
||
cov.start() | ||
#Discover the test and execute them: | ||
loader = unittest.TestLoader() | ||
tests = loader.discover('./test/') | ||
testRunner = unittest.runner.TextTestRunner(descriptions=True, verbosity=1) | ||
testRunner.run(tests) | ||
cov.stop() | ||
|
||
cov.html_report() | ||
|
||
if __name__ == '__main__': | ||
main() |