From: Ezio Melotti Date: Tue, 12 Apr 2011 12:59:50 +0000 (+0300) Subject: #9233: skip _json-specific tests when _json is not available. X-Git-Tag: v2.7.2rc1~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b93021214531e1b825dd31e802838191beae581;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 bf3ccd5eb9..2a7ec82825 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): self._test_scanstring(json.decoder.c_scanstring) diff --git a/Lib/json/tests/test_speedups.py b/Lib/json/tests/test_speedups.py index 3b4ccb34f4..c6051cf218 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")