[Python-checkins] cpython (2.7): #9233: skip _json-specific tests when _json is not available.

ezio.melotti python-checkins at python.org
Tue Apr 12 15:07:27 CEST 2011


http://hg.python.org/cpython/rev/500063f6ae5a
changeset:   69266:500063f6ae5a
branch:      2.7
parent:      69264:7b71872fb66a
user:        Ezio Melotti
date:        Tue Apr 12 15:59:50 2011 +0300
summary:
  #9233: skip _json-specific tests when _json is not available.

files:
  Lib/json/tests/test_scanstring.py |  8 +++++++-
  Lib/json/tests/test_speedups.py   |  8 +++++++-
  2 files changed, 14 insertions(+), 2 deletions(-)


diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py
--- a/Lib/json/tests/test_scanstring.py
+++ b/Lib/json/tests/test_scanstring.py
@@ -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)
 
diff --git a/Lib/json/tests/test_speedups.py b/Lib/json/tests/test_speedups.py
--- a/Lib/json/tests/test_speedups.py
+++ b/Lib/json/tests/test_speedups.py
@@ -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
+
+ at skipUnless(_json, 'test requires the _json module')
 class TestSpeedups(TestCase):
     def test_scanstring(self):
         self.assertEqual(decoder.scanstring.__module__, "_json")

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list