diff options
| author | Gregory P. Smith <greg@krypto.org> | 2011-05-14 22:26:35 (GMT) |
|---|---|---|
| committer | Gregory P. Smith <greg@krypto.org> | 2011-05-14 22:26:35 (GMT) |
| commit | 873cab28903eb6a9063b502d7e9fe9555fc0cfd7 (patch) | |
| tree | ec7079b6ae9ce221158c134d18b64a336284d115 /Lib/test/json_tests/test_scanstring.py | |
| parent | 12c9d028ed0a1803019f3796014e75c74d9de2f6 (diff) | |
| parent | 95e686686f600e6df18c32a5e808949517655868 (diff) | |
| download | cpython-873cab28903eb6a9063b502d7e9fe9555fc0cfd7.zip cpython-873cab28903eb6a9063b502d7e9fe9555fc0cfd7.tar.gz cpython-873cab28903eb6a9063b502d7e9fe9555fc0cfd7.tar.bz2 | |
merge heads.
Diffstat (limited to 'Lib/test/json_tests/test_scanstring.py')
| -rw-r--r-- | Lib/test/json_tests/test_scanstring.py | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Lib/test/json_tests/test_scanstring.py b/Lib/test/json_tests/test_scanstring.py index abd3253..f82cdee 100644 --- a/Lib/test/json_tests/test_scanstring.py +++ b/Lib/test/json_tests/test_scanstring.py @@ -1,24 +1,10 @@ import sys -from unittest import TestCase, skipUnless +from test.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 |
