Permalink
Browse files

Support `setup.py test --coverage` in affiliated packages.

  • Loading branch information...
1 parent 0811108 commit 97a1e5b017375ef421a523d6c73cb5c964b80f9d @mdboom mdboom committed Feb 27, 2014
Showing with 37 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +12 −0 README.rst
  3. +20 −0 packagename/tests/coveragerc
  4. +3 −0 packagename/tests/setup_package.py
View
@@ -11,6 +11,8 @@ __pycache__
# Other generated files
*/version.py
+htmlcov
+.coverage
# Sphinx
_build
View
@@ -140,6 +140,18 @@ will be clear from context what to do with your particular VCS.
git mv docs/packagename docs/yourpkg
git commit -m "Updated docs to reflect new project yourpkg"
+* (Optional) If you want integrated coverage testing, update the
+ coverage configuration. Open ``yourpkg/tests/coveragerc`` in a text
+ editor and change the ``source = packagename`` line to refer to the
+ name of your package. Any other project-specific settings for
+ ``coverage.py`` can be added here. Open
+ ``yourpkg/tests/setup_package.py`` and replace the package name
+ ``packages.tests`` with ``yourpkg.tests``. Then do::
+
+ git add yourpkg/tests/coveragerc
+ git add yourpkg/tests/setup_package.py
+ git commit -m "Update coveragerc settings"
+
* Adjust the ``MANIFEST.in`` file to reflect your package's name by changing
the line 4 from ``recursive-include packagename *.pyx *.c`` to
``recursive-include yourpkg *.pyx *.c`` and pass this onto git::
@@ -0,0 +1,20 @@
+[run]
+source = packagename
+
+[report]
+exclude_lines =
+ # Have to re-enable the standard pragma
+ pragma: no cover
+
+ # Don't complain about packages we have installed
+ except ImportError
+
+ # Don't complain if tests don't hit assertions
+ raise AssertionError
+ raise NotImplementedError
+
+ # Don't complain about script hooks
+ def main\(.*\):
+
+ # Ignore branches that don't pertain to this version of Python
+ pragma: py{ignore_python_version}
@@ -0,0 +1,3 @@
+def get_package_data():
+ return {
+ 'packagename.tests': ['coveragerc']}

0 comments on commit 97a1e5b

Please sign in to comment.