summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile17
-rwxr-xr-xtests.py31
2 files changed, 19 insertions, 29 deletions
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()