diff options
| author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-14 03:38:03 (GMT) |
|---|---|---|
| committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-14 03:38:03 (GMT) |
| commit | 3c0d8a1cc728a92671a9f3d4cbf6636453707385 (patch) | |
| tree | 8aa66aa9741888b7613c518664f607308aa1670a /Lib/json/tests/test_scanstring.py | |
| parent | fec3ad103613b46c9821f210581efca6fedcb9a9 (diff) | |
| download | cpython-3c0d8a1cc728a92671a9f3d4cbf6636453707385.zip cpython-3c0d8a1cc728a92671a9f3d4cbf6636453707385.tar.gz cpython-3c0d8a1cc728a92671a9f3d4cbf6636453707385.tar.bz2 | |
#5723: Improve json tests to be executed with and without accelerations.
Diffstat (limited to 'Lib/json/tests/test_scanstring.py')
| -rw-r--r-- | Lib/json/tests/test_scanstring.py | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py index abd3253..9c406d5 100644 --- a/Lib/json/tests/test_scanstring.py +++ b/Lib/json/tests/test_scanstring.py @@ -1,24 +1,10 @@ import sys -from unittest import TestCase, skipUnless +from json.tests import PyTest, CTest -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) - - def _test_scanstring(self, scanstring): +class TestScanstring: + def test_scanstring(self): + scanstring = self.json.decoder.scanstring self.assertEqual( scanstring('"z\\ud834\\udd20x"', 1, True), ('z\U0001d120x', 16)) @@ -109,4 +95,9 @@ class TestScanString(TestCase): ('Bad value', 12)) def test_overflow(self): - self.assertRaises(OverflowError, json.decoder.scanstring, b"xxx", sys.maxsize+1) + with self.assertRaises(OverflowError): + self.json.decoder.scanstring(b"xxx", sys.maxsize+1) + + +class TestPyScanstring(TestScanstring, PyTest): pass +class TestCScanstring(TestScanstring, CTest): pass |
