summaryrefslogtreecommitdiff
path: root/simplejson/tests
diff options
context:
space:
mode:
authorBob Ippolito <bob@redivi.com>2012-12-28 19:17:54 -0800
committerBob Ippolito <bob@redivi.com>2012-12-28 19:17:54 -0800
commit0bc9e8a586a6c2e4a85b3896a71fc04ed718cbfd (patch)
tree8b146fcb9078ad4277c3b6c75856482053d43798 /simplejson/tests
parent77850638e824d23e3301962b3b142fe2e0520abb (diff)
downloadsimplejson-0bc9e8a586a6c2e4a85b3896a71fc04ed718cbfd.tar.gz
start working on improving coverage, remove unused bytes code paths from py3
Diffstat (limited to 'simplejson/tests')
-rw-r--r--simplejson/tests/__init__.py18
-rw-r--r--simplejson/tests/test_scanstring.py8
2 files changed, 22 insertions, 4 deletions
diff --git a/simplejson/tests/__init__.py b/simplejson/tests/__init__.py
index 064b598..da21365 100644
--- a/simplejson/tests/__init__.py
+++ b/simplejson/tests/__init__.py
@@ -1,17 +1,27 @@
from __future__ import absolute_import
import unittest
import doctest
+import sys
class OptionalExtensionTestSuite(unittest.TestSuite):
def run(self, result):
import simplejson
run = unittest.TestSuite.run
run(self, result)
- simplejson._toggle_speedups(False)
- run(self, result)
- simplejson._toggle_speedups(True)
+ if simplejson._import_c_make_encoder() is None:
+ TestMissingSpeedups().run(result)
+ else:
+ simplejson._toggle_speedups(False)
+ run(self, result)
+ simplejson._toggle_speedups(True)
return result
+class TestMissingSpeedups(unittest.TestCase):
+ def runTest(self):
+ if hasattr(sys, 'pypy_translation_info'):
+ "PyPy doesn't need speedups! :)"
+ elif hasattr(self, 'skipTest'):
+ self.skipTest('_speedups.so is missing!')
def additional_tests(suite=None):
import simplejson
@@ -55,7 +65,7 @@ def all_tests_suite():
def main():
- runner = unittest.TextTestRunner()
+ runner = unittest.TextTestRunner(verbosity=1 + sys.argv.count('-v'))
suite = all_tests_suite()
raise SystemExit(not runner.run(suite).wasSuccessful())
diff --git a/simplejson/tests/test_scanstring.py b/simplejson/tests/test_scanstring.py
index 4045fec..297bc1b 100644
--- a/simplejson/tests/test_scanstring.py
+++ b/simplejson/tests/test_scanstring.py
@@ -6,6 +6,14 @@ import simplejson.decoder
from simplejson.compat import b
class TestScanString(TestCase):
+ # The bytes type is intentionally not used in most of these tests
+ # under Python 3 because the decoder immediately coerces to str before
+ # calling scanstring. In Python 2 we are testing the code paths
+ # for both unicode and str.
+ #
+ # The reason this is done is because Python 3 would require
+ # entirely different code paths for parsing bytes and str.
+ #
def test_py_scanstring(self):
self._test_scanstring(simplejson.decoder.py_scanstring)