Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add coverage command.

git-svn-id: https://svn.apache.org/repos/asf/incubator/libcloud/trunk@1081243 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 4c36877fc76303688e06d6e0c98db8149b4a40ed 1 parent 5da3950
@Kami Kami authored
Showing with 55 additions and 2 deletions.
  1. +27 −0 .coveragerc
  2. +28 −2 setup.py
View
27 .coveragerc
@@ -0,0 +1,27 @@
+# .coveragerc to control coverage.py
+[run]
+branch = True
+source = libcloud
+
+[report]
+# Regexes for lines to exclude from consideration
+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__.:
+
+ignore_errors = True
+
+[html]
+directory = coverage_html_report
View
30 setup.py
@@ -41,6 +41,10 @@ def finalize_options(self):
pass
def run(self):
+ status = self._run_tests()
+ sys.exit(status)
+
+ def _run_tests(self):
secrets = pjoin(self._dir, 'test', 'secrets.py')
if not os.path.isfile(secrets):
print "Missing %s" % (secrets)
@@ -77,7 +81,7 @@ def run(self):
tests = TestLoader().loadTestsFromNames(testfiles)
t = TextTestRunner(verbosity = 2)
res = t.run(tests)
- sys.exit(not res.wasSuccessful())
+ return not res.wasSuccessful()
class ApiDocsCommand(Command):
user_options = []
@@ -100,6 +104,27 @@ def run(self):
% (HTML_VIEWSOURCE_BASE, PROJECT_BASE_DIR)
)
+class CoverageCommand(Command):
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ import coverage
+ cov = coverage.coverage(config_file='.coveragerc')
+ cov.start()
+
+ tc = TestCommand(self.distribution)
+ tc._run_tests()
+
+ cov.stop()
+ cov.save()
+ cov.html_report()
+
# pre-2.6 will need the ssl PyPI package
pre_python26 = (sys.version_info[0] == 2 and sys.version_info[1] < 6)
@@ -125,7 +150,8 @@ def run(self):
url='http://incubator.apache.org/libcloud/',
cmdclass={
'test': TestCommand,
- 'apidocs': ApiDocsCommand
+ 'apidocs': ApiDocsCommand,
+ 'coverage': CoverageCommand
},
classifiers=[
'Development Status :: 4 - Beta',
Please sign in to comment.
Something went wrong with that request. Please try again.