]> granicus.if.org Git - python/commitdiff
#9233: skip _json-specific tests when _json is not available.
authorEzio Melotti <none@none>
Tue, 12 Apr 2011 12:59:50 +0000 (15:59 +0300)
committerEzio Melotti <none@none>
Tue, 12 Apr 2011 12:59:50 +0000 (15:59 +0300)
Lib/json/tests/test_scanstring.py
Lib/json/tests/test_speedups.py

index bf3ccd5eb9bd7b53e55ff0c10c5edb8af157f274..2a7ec82825aef3fc72c762eee8304d2ab1a9610d 100644 (file)
@@ -1,14 +1,20 @@
 import sys
 import decimal
-from unittest import TestCase
+from unittest import TestCase, skipUnless
 
 import json
 import json.decoder
 
+try:
+    import _json
+except ImportError:
+    _json = None
+
 class TestScanString(TestCase):
     def test_py_scanstring(self):
         self._test_scanstring(json.decoder.py_scanstring)
 
+    @skipUnless(_json, 'test requires the _json module')
     def test_c_scanstring(self):
         self._test_scanstring(json.decoder.c_scanstring)
 
index 3b4ccb34f4fbfd3d51d689ab0f1bda487e818ec3..c6051cf218c4888937f2178afe0ff9c8cf25d117 100644 (file)
@@ -1,8 +1,14 @@
 import decimal
-from unittest import TestCase
+from unittest import TestCase, skipUnless
 
 from json import decoder, encoder, scanner
 
+try:
+    import _json
+except ImportError:
+    _json = None
+
+@skipUnless(_json, 'test requires the _json module')
 class TestSpeedups(TestCase):
     def test_scanstring(self):
         self.assertEqual(decoder.scanstring.__module__, "_json")