From 2270facee9aa0740972d28dc64e1d921bffd857a Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 2 May 2011 14:59:59 +0200 Subject: [PATCH] Add test coverage. --- .gitignore | 1 + Makefile | 3 +++ weasy/tests/__main__.py | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7fdea582..6ffac1c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyc *.egg-info +.coverage diff --git a/Makefile b/Makefile index 7ae0b4c7..fe5d0684 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ test: python2 -m weasy.tests +coverage: + python2 -m weasy.tests --cover + diff --git a/weasy/tests/__main__.py b/weasy/tests/__main__.py index 796c323a..e9bdbc97 100644 --- a/weasy/tests/__main__.py +++ b/weasy/tests/__main__.py @@ -16,7 +16,21 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import sys from weasy.tests import all if __name__ == '__main__': - all.main() + if '--cover' in sys.argv: + sys.argv.remove('--cover') # Attest complains on unknown options + from coverage import coverage + cover = coverage() + cover.start() + all.main() + cover.stop() + cover.report([module for name, module in sys.modules.iteritems() + # Imported modules end up in sys.modules as None + # eg. sys.modules['weasy.css.cssutils'] == None + # Is it because of the Attest import hook? + if module and name.startswith('weasy')]) + else: + all.main()