From: Ezio Melotti Date: Wed, 13 Apr 2011 03:58:29 +0000 (+0300) Subject: #9233: skip _json-specific tests when _json is not available. X-Git-Tag: v3.2.1b1~135^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f95a52fe24cd136da5634747d5334c86d400d2d;p=python #9233: skip _json-specific tests when _json is not available. --- diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py index d503851e56..8f5999eff3 100644 --- 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): if json.decoder.c_scanstring is not None: self._test_scanstring(json.decoder.c_scanstring) diff --git a/Lib/json/tests/test_speedups.py b/Lib/json/tests/test_speedups.py index 94381548a7..6f34cacc35 100644 --- 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 + +@skipUnless(_json, 'test requires the _json module') class TestSpeedups(TestCase): def test_scanstring(self): self.assertEqual(decoder.scanstring.__module__, "_json")