summaryrefslogtreecommitdiffstats
path: root/Lib/json
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-11-21 01:30:29 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-11-21 01:30:29 (GMT)
commit19f2aeba67b5b4dc4dfd589d02d4a0b0804e22ee (patch)
tree596b5a2c45b058ea3e0cdc49cb7539a21410b98d /Lib/json
parentb65b4937e20be4a2d3311326909c77bbf2e1c4cd (diff)
downloadcpython-19f2aeba67b5b4dc4dfd589d02d4a0b0804e22ee.zip
cpython-19f2aeba67b5b4dc4dfd589d02d4a0b0804e22ee.tar.gz
cpython-19f2aeba67b5b4dc4dfd589d02d4a0b0804e22ee.tar.bz2
Merged revisions 86596 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86596 | ezio.melotti | 2010-11-20 21:04:17 +0200 (Sat, 20 Nov 2010) | 1 line #9424: Replace deprecated assert* methods in the Python test suite. ........
Diffstat (limited to 'Lib/json')
-rw-r--r--Lib/json/tests/test_decode.py6
-rw-r--r--Lib/json/tests/test_default.py2
-rw-r--r--Lib/json/tests/test_dump.py8
-rw-r--r--Lib/json/tests/test_encode_basestring_ascii.py2
-rw-r--r--Lib/json/tests/test_float.py8
-rw-r--r--Lib/json/tests/test_indent.py6
-rw-r--r--Lib/json/tests/test_pass1.py2
-rw-r--r--Lib/json/tests/test_pass2.py2
-rw-r--r--Lib/json/tests/test_pass3.py2
-rw-r--r--Lib/json/tests/test_recursion.py2
-rw-r--r--Lib/json/tests/test_scanstring.py44
-rw-r--r--Lib/json/tests/test_separators.py6
-rw-r--r--Lib/json/tests/test_speedups.py4
-rw-r--r--Lib/json/tests/test_unicode.py24
14 files changed, 59 insertions, 59 deletions
diff --git a/Lib/json/tests/test_decode.py b/Lib/json/tests/test_decode.py
index 4610c6c..74d886a 100644
--- a/Lib/json/tests/test_decode.py
+++ b/Lib/json/tests/test_decode.py
@@ -9,12 +9,12 @@ class TestDecode(TestCase):
def test_decimal(self):
rval = json.loads('1.1', parse_float=decimal.Decimal)
self.assertTrue(isinstance(rval, decimal.Decimal))
- self.assertEquals(rval, decimal.Decimal('1.1'))
+ self.assertEqual(rval, decimal.Decimal('1.1'))
def test_float(self):
rval = json.loads('1', parse_int=float)
self.assertTrue(isinstance(rval, float))
- self.assertEquals(rval, 1.0)
+ self.assertEqual(rval, 1.0)
def test_object_pairs_hook(self):
s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
@@ -38,4 +38,4 @@ class TestDecode(TestCase):
# the whitespace regex, so this test is designed to try and
# exercise the uncommon cases. The array cases are already covered.
rval = json.loads('{ "key" : "value" , "k":"v" }')
- self.assertEquals(rval, {"key":"value", "k":"v"})
+ self.assertEqual(rval, {"key":"value", "k":"v"})
diff --git a/Lib/json/tests/test_default.py b/Lib/json/tests/test_default.py
index 49f05ad..6a03eeb 100644
--- a/Lib/json/tests/test_default.py
+++ b/Lib/json/tests/test_default.py
@@ -4,6 +4,6 @@ import json
class TestDefault(TestCase):
def test_default(self):
- self.assertEquals(
+ self.assertEqual(
json.dumps(type, default=repr),
json.dumps(repr(type)))
diff --git a/Lib/json/tests/test_dump.py b/Lib/json/tests/test_dump.py
index 54e218f..8df234b 100644
--- a/Lib/json/tests/test_dump.py
+++ b/Lib/json/tests/test_dump.py
@@ -7,15 +7,15 @@ class TestDump(TestCase):
def test_dump(self):
sio = StringIO()
json.dump({}, sio)
- self.assertEquals(sio.getvalue(), '{}')
+ self.assertEqual(sio.getvalue(), '{}')
def test_dumps(self):
- self.assertEquals(json.dumps({}), '{}')
+ self.assertEqual(json.dumps({}), '{}')
def test_encode_truefalse(self):
- self.assertEquals(json.dumps(
+ self.assertEqual(json.dumps(
{True: False, False: True}, sort_keys=True),
'{"false": true, "true": false}')
- self.assertEquals(json.dumps(
+ self.assertEqual(json.dumps(
{2: 3.0, 4.0: 5, False: 1, 6: True}, sort_keys=True),
'{"false": 1, "2": 3.0, "4.0": 5, "6": true}')
diff --git a/Lib/json/tests/test_encode_basestring_ascii.py b/Lib/json/tests/test_encode_basestring_ascii.py
index dbcb09a..4fddd12 100644
--- a/Lib/json/tests/test_encode_basestring_ascii.py
+++ b/Lib/json/tests/test_encode_basestring_ascii.py
@@ -34,7 +34,7 @@ class TestEncodeBaseStringAscii(TestCase):
fname = encode_basestring_ascii.__name__
for input_string, expect in CASES:
result = encode_basestring_ascii(input_string)
- self.assertEquals(result, expect,
+ self.assertEqual(result, expect,
'{0!r} != {1!r} for {2}({3!r})'.format(
result, expect, fname, input_string))
diff --git a/Lib/json/tests/test_float.py b/Lib/json/tests/test_float.py
index 2d4aea2..ca4a506 100644
--- a/Lib/json/tests/test_float.py
+++ b/Lib/json/tests/test_float.py
@@ -6,10 +6,10 @@ import json
class TestFloat(TestCase):
def test_floats(self):
for num in [1617161771.7650001, math.pi, math.pi**100, math.pi**-100, 3.1]:
- self.assertEquals(float(json.dumps(num)), num)
- self.assertEquals(json.loads(json.dumps(num)), num)
+ self.assertEqual(float(json.dumps(num)), num)
+ self.assertEqual(json.loads(json.dumps(num)), num)
def test_ints(self):
for num in [1, 1<<32, 1<<64]:
- self.assertEquals(json.dumps(num), str(num))
- self.assertEquals(int(json.dumps(num)), num)
+ self.assertEqual(json.dumps(num), str(num))
+ self.assertEqual(int(json.dumps(num)), num)
diff --git a/Lib/json/tests/test_indent.py b/Lib/json/tests/test_indent.py
index 6055162..cd608d9 100644
--- a/Lib/json/tests/test_indent.py
+++ b/Lib/json/tests/test_indent.py
@@ -36,6 +36,6 @@ class TestIndent(TestCase):
h1 = json.loads(d1)
h2 = json.loads(d2)
- self.assertEquals(h1, h)
- self.assertEquals(h2, h)
- self.assertEquals(d2, expect)
+ self.assertEqual(h1, h)
+ self.assertEqual(h2, h)
+ self.assertEqual(d2, expect)
diff --git a/Lib/json/tests/test_pass1.py b/Lib/json/tests/test_pass1.py
index 216e252..719c113 100644
--- a/Lib/json/tests/test_pass1.py
+++ b/Lib/json/tests/test_pass1.py
@@ -67,7 +67,7 @@ class TestPass1(TestCase):
# test in/out equivalence and parsing
res = json.loads(JSON)
out = json.dumps(res)
- self.assertEquals(res, json.loads(out))
+ self.assertEqual(res, json.loads(out))
try:
json.dumps(res, allow_nan=False)
except ValueError:
diff --git a/Lib/json/tests/test_pass2.py b/Lib/json/tests/test_pass2.py
index 80d8433..379117e 100644
--- a/Lib/json/tests/test_pass2.py
+++ b/Lib/json/tests/test_pass2.py
@@ -11,4 +11,4 @@ class TestPass2(TestCase):
# test in/out equivalence and parsing
res = json.loads(JSON)
out = json.dumps(res)
- self.assertEquals(res, json.loads(out))
+ self.assertEqual(res, json.loads(out))
diff --git a/Lib/json/tests/test_pass3.py b/Lib/json/tests/test_pass3.py
index 77d87b2..9151c43 100644
--- a/Lib/json/tests/test_pass3.py
+++ b/Lib/json/tests/test_pass3.py
@@ -17,4 +17,4 @@ class TestPass3(TestCase):
# test in/out equivalence and parsing
res = json.loads(JSON)
out = json.dumps(res)
- self.assertEquals(res, json.loads(out))
+ self.assertEqual(res, json.loads(out))
diff --git a/Lib/json/tests/test_recursion.py b/Lib/json/tests/test_recursion.py
index 073d3c1..1e9b8ab 100644
--- a/Lib/json/tests/test_recursion.py
+++ b/Lib/json/tests/test_recursion.py
@@ -57,7 +57,7 @@ class TestRecursion(TestCase):
def test_defaultrecursion(self):
enc = RecursiveJSONEncoder()
- self.assertEquals(enc.encode(JSONTestObject), '"JSONTestObject"')
+ self.assertEqual(enc.encode(JSONTestObject), '"JSONTestObject"')
enc.recurse = True
try:
enc.encode(JSONTestObject)
diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py
index 2e9136b..d503851 100644
--- a/Lib/json/tests/test_scanstring.py
+++ b/Lib/json/tests/test_scanstring.py
@@ -14,92 +14,92 @@ class TestScanString(TestCase):
self._test_scanstring(json.decoder.c_scanstring)
def _test_scanstring(self, scanstring):
- self.assertEquals(
+ self.assertEqual(
scanstring('"z\\ud834\\udd20x"', 1, True),
('z\U0001d120x', 16))
if sys.maxunicode == 65535:
- self.assertEquals(
+ self.assertEqual(
scanstring('"z\U0001d120x"', 1, True),
('z\U0001d120x', 6))
else:
- self.assertEquals(
+ self.assertEqual(
scanstring('"z\U0001d120x"', 1, True),
('z\U0001d120x', 5))
- self.assertEquals(
+ self.assertEqual(
scanstring('"\\u007b"', 1, True),
('{', 8))
- self.assertEquals(
+ self.assertEqual(
scanstring('"A JSON payload should be an object or array, not a string."', 1, True),
('A JSON payload should be an object or array, not a string.', 60))
- self.assertEquals(
+ self.assertEqual(
scanstring('["Unclosed array"', 2, True),
('Unclosed array', 17))
- self.assertEquals(
+ self.assertEqual(
scanstring('["extra comma",]', 2, True),
('extra comma', 14))
- self.assertEquals(
+ self.assertEqual(
scanstring('["double extra comma",,]', 2, True),
('double extra comma', 21))
- self.assertEquals(
+ self.assertEqual(
scanstring('["Comma after the close"],', 2, True),
('Comma after the close', 24))
- self.assertEquals(
+ self.assertEqual(
scanstring('["Extra close"]]', 2, True),
('Extra close', 14))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Extra comma": true,}', 2, True),
('Extra comma', 14))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Extra value after close": true} "misplaced quoted value"', 2, True),
('Extra value after close', 26))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Illegal expression": 1 + 2}', 2, True),
('Illegal expression', 21))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Illegal invocation": alert()}', 2, True),
('Illegal invocation', 21))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Numbers cannot have leading zeroes": 013}', 2, True),
('Numbers cannot have leading zeroes', 37))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Numbers cannot be hex": 0x14}', 2, True),
('Numbers cannot be hex', 24))
- self.assertEquals(
+ self.assertEqual(
scanstring('[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]', 21, True),
('Too deep', 30))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Missing colon" null}', 2, True),
('Missing colon', 16))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Double colon":: null}', 2, True),
('Double colon', 15))
- self.assertEquals(
+ self.assertEqual(
scanstring('{"Comma instead of colon", null}', 2, True),
('Comma instead of colon', 25))
- self.assertEquals(
+ self.assertEqual(
scanstring('["Colon instead of comma": false]', 2, True),
('Colon instead of comma', 25))
- self.assertEquals(
+ self.assertEqual(
scanstring('["Bad value", truth]', 2, True),
('Bad value', 12))
diff --git a/Lib/json/tests/test_separators.py b/Lib/json/tests/test_separators.py
index 32db341..d5b92bd 100644
--- a/Lib/json/tests/test_separators.py
+++ b/Lib/json/tests/test_separators.py
@@ -37,6 +37,6 @@ class TestSeparators(TestCase):
h1 = json.loads(d1)
h2 = json.loads(d2)
- self.assertEquals(h1, h)
- self.assertEquals(h2, h)
- self.assertEquals(d2, expect)
+ self.assertEqual(h1, h)
+ self.assertEqual(h2, h)
+ self.assertEqual(d2, expect)
diff --git a/Lib/json/tests/test_speedups.py b/Lib/json/tests/test_speedups.py
index 29e40ac..9438154 100644
--- a/Lib/json/tests/test_speedups.py
+++ b/Lib/json/tests/test_speedups.py
@@ -5,11 +5,11 @@ from json import decoder, encoder, scanner
class TestSpeedups(TestCase):
def test_scanstring(self):
- self.assertEquals(decoder.scanstring.__module__, "_json")
+ self.assertEqual(decoder.scanstring.__module__, "_json")
self.assertTrue(decoder.scanstring is decoder.c_scanstring)
def test_encode_basestring_ascii(self):
- self.assertEquals(encoder.encode_basestring_ascii.__module__, "_json")
+ self.assertEqual(encoder.encode_basestring_ascii.__module__, "_json")
self.assertTrue(encoder.encode_basestring_ascii is
encoder.c_encode_basestring_ascii)
diff --git a/Lib/json/tests/test_unicode.py b/Lib/json/tests/test_unicode.py
index 12de83c..e336c91 100644
--- a/Lib/json/tests/test_unicode.py
+++ b/Lib/json/tests/test_unicode.py
@@ -10,43 +10,43 @@ class TestUnicode(TestCase):
def test_encoding3(self):
u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = json.dumps(u)
- self.assertEquals(j, '"\\u03b1\\u03a9"')
+ self.assertEqual(j, '"\\u03b1\\u03a9"')
def test_encoding4(self):
u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = json.dumps([u])
- self.assertEquals(j, '["\\u03b1\\u03a9"]')
+ self.assertEqual(j, '["\\u03b1\\u03a9"]')
def test_encoding5(self):
u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = json.dumps(u, ensure_ascii=False)
- self.assertEquals(j, '"{0}"'.format(u))
+ self.assertEqual(j, '"{0}"'.format(u))
def test_encoding6(self):
u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
j = json.dumps([u], ensure_ascii=False)
- self.assertEquals(j, '["{0}"]'.format(u))
+ self.assertEqual(j, '["{0}"]'.format(u))
def test_big_unicode_encode(self):
u = '\U0001d120'
- self.assertEquals(json.dumps(u), '"\\ud834\\udd20"')
- self.assertEquals(json.dumps(u, ensure_ascii=False), '"\U0001d120"')
+ self.assertEqual(json.dumps(u), '"\\ud834\\udd20"')
+ self.assertEqual(json.dumps(u, ensure_ascii=False), '"\U0001d120"')
def test_big_unicode_decode(self):
u = 'z\U0001d120x'
- self.assertEquals(json.loads('"' + u + '"'), u)
- self.assertEquals(json.loads('"z\\ud834\\udd20x"'), u)
+ self.assertEqual(json.loads('"' + u + '"'), u)
+ self.assertEqual(json.loads('"z\\ud834\\udd20x"'), u)
def test_unicode_decode(self):
for i in range(0, 0xd7ff):
u = chr(i)
s = '"\\u{0:04x}"'.format(i)
- self.assertEquals(json.loads(s), u)
+ self.assertEqual(json.loads(s), u)
def test_unicode_preservation(self):
- self.assertEquals(type(json.loads('""')), str)
- self.assertEquals(type(json.loads('"a"')), str)
- self.assertEquals(type(json.loads('["a"]')[0]), str)
+ self.assertEqual(type(json.loads('""')), str)
+ self.assertEqual(type(json.loads('"a"')), str)
+ self.assertEqual(type(json.loads('["a"]')[0]), str)
def test_bytes_encode(self):
self.assertRaises(TypeError, json.dumps, b"hi")