From faa346f16ba586e1c5e1030437cdae9061b79b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sun, 7 Jul 2013 18:48:32 +0200 Subject: move coverage code from tests.py to makefile --- makefile | 17 +++++++++++++++++ tests.py | 31 ++----------------------------- 2 files changed, 19 insertions(+), 29 deletions(-) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000..e0a2fcf --- /dev/null +++ b/makefile @@ -0,0 +1,17 @@ + +help: + @echo "jsonpointer" + @echo "Makefile targets" + @echo " - test: run tests" + @echo " - coverage: run tests with coverage" + @echo + @echo "To install jsonpointer, type" + @echo " python setup.py install" + @echo + +test: + python tests.py + +coverage: + coverage run --source=jsonpointer tests.py + coverage report -m diff --git a/tests.py b/tests.py index 5f15a25..762313d 100755 --- a/tests.py +++ b/tests.py @@ -62,45 +62,18 @@ class ComparisonTests(unittest.TestCase): self.assertNotEqual(hash(p1), hash(p3)) self.assertNotEqual(hash(p2), hash(p3)) - - - -modules = ['jsonpointer'] -coverage_modules = [] - suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(SpecificationTests)) suite.addTest(unittest.makeSuite(ComparisonTests)) +modules = ['jsonpointer'] + for module in modules: m = __import__(module, fromlist=[module]) - coverage_modules.append(m) suite.addTest(doctest.DocTestSuite(m)) runner = unittest.TextTestRunner(verbosity=1) - -try: - import coverage -except ImportError: - coverage = None - -if coverage is not None: - coverage.erase() - coverage.start() - result = runner.run(suite) if not result.wasSuccessful(): sys.exit(1) - -if coverage is not None: - coverage.stop() - coverage.report(coverage_modules) - coverage.erase() - -if coverage is None: - sys.stderr.write(""" -No coverage reporting done (Python module "coverage" is missing) -Please install the python-coverage package to get coverage reporting. -""") - sys.stderr.flush() -- cgit v1.2.1