summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests.py b/tests.py
new file mode 100755
index 0000000..5fe7beb
--- /dev/null
+++ b/tests.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import doctest
+import unittest
+import sys
+
+modules = ['jsonpatch']
+coverage_modules = []
+
+suite = unittest.TestSuite()
+
+for module in modules:
+ m = __import__(module, fromlist=[module])
+ coverage_modules.append(m)
+ suite.addTest(doctest.DocTestSuite(m))
+
+runner = unittest.TextTestRunner(verbosity=2)
+
+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:
+ print >>sys.stderr, """
+ No coverage reporting done (Python module "coverage" is missing)
+ Please install the python-coverage package to get coverage reporting.
+ """