mirror of
https://github.com/python/cpython.git
synced 2025-10-19 21:28:02 +00:00
#9233: skip _json-specific tests when _json is not available.
This commit is contained in:
parent
a8b0f9adfe
commit
4f95a52fe2
2 changed files with 14 additions and 2 deletions
|
@ -1,14 +1,20 @@
|
||||||
import sys
|
import sys
|
||||||
import decimal
|
import decimal
|
||||||
from unittest import TestCase
|
from unittest import TestCase, skipUnless
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import json.decoder
|
import json.decoder
|
||||||
|
|
||||||
|
try:
|
||||||
|
import _json
|
||||||
|
except ImportError:
|
||||||
|
_json = None
|
||||||
|
|
||||||
class TestScanString(TestCase):
|
class TestScanString(TestCase):
|
||||||
def test_py_scanstring(self):
|
def test_py_scanstring(self):
|
||||||
self._test_scanstring(json.decoder.py_scanstring)
|
self._test_scanstring(json.decoder.py_scanstring)
|
||||||
|
|
||||||
|
@skipUnless(_json, 'test requires the _json module')
|
||||||
def test_c_scanstring(self):
|
def test_c_scanstring(self):
|
||||||
if json.decoder.c_scanstring is not None:
|
if json.decoder.c_scanstring is not None:
|
||||||
self._test_scanstring(json.decoder.c_scanstring)
|
self._test_scanstring(json.decoder.c_scanstring)
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
import decimal
|
import decimal
|
||||||
from unittest import TestCase
|
from unittest import TestCase, skipUnless
|
||||||
|
|
||||||
from json import decoder, encoder, scanner
|
from json import decoder, encoder, scanner
|
||||||
|
|
||||||
|
try:
|
||||||
|
import _json
|
||||||
|
except ImportError:
|
||||||
|
_json = None
|
||||||
|
|
||||||
|
@skipUnless(_json, 'test requires the _json module')
|
||||||
class TestSpeedups(TestCase):
|
class TestSpeedups(TestCase):
|
||||||
def test_scanstring(self):
|
def test_scanstring(self):
|
||||||
self.assertEqual(decoder.scanstring.__module__, "_json")
|
self.assertEqual(decoder.scanstring.__module__, "_json")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue