Mercurial > cpython-lru_cache-weakref
annotate Lib/json/tests/test_dump.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 5b0fecd2eba0 |
| children | 33ae62a4ecf5 |
| rev | line source |
|---|---|
|
46676
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
1 from cStringIO import StringIO |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
2 from json.tests import PyTest, CTest |
|
46676
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
3 |
|
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
4 |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
5 class TestDump(object): |
|
46676
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
6 def test_dump(self): |
|
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
7 sio = StringIO() |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
8 self.json.dump({}, sio) |
|
66348
614c84670c63
Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents:
58498
diff
changeset
|
9 self.assertEqual(sio.getvalue(), '{}') |
|
46676
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
10 |
|
4ded35754cb7
Add the 'json' package. Code taken from simplejson 1.9 and contributed by Bob
Brett Cannon <bcannon@gmail.com>
parents:
diff
changeset
|
11 def test_dumps(self): |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
12 self.assertEqual(self.dumps({}), '{}') |
|
52199
d95e5add3ca4
merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents:
46676
diff
changeset
|
13 |
|
d95e5add3ca4
merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents:
46676
diff
changeset
|
14 def test_encode_truefalse(self): |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
15 self.assertEqual(self.dumps( |
|
52199
d95e5add3ca4
merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents:
46676
diff
changeset
|
16 {True: False, False: True}, sort_keys=True), |
|
d95e5add3ca4
merge json library with simplejson 2.0.9 (issue 4136)
Bob Ippolito <bob@redivi.com>
parents:
46676
diff
changeset
|
17 '{"false": true, "true": false}') |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
18 self.assertEqual(self.dumps( |
|
58498
22aea131b6af
#7092: fix DeprecationWarnings for json when the tests are run with -3 -Wd.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
52199
diff
changeset
|
19 {2: 3.0, 4.0: 5L, False: 1, 6L: True}, sort_keys=True), |
|
22aea131b6af
#7092: fix DeprecationWarnings for json when the tests are run with -3 -Wd.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
52199
diff
changeset
|
20 '{"false": 1, "2": 3.0, "4.0": 5, "6": true}') |
|
70084
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
21 |
|
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
22 class TestPyDump(TestDump, PyTest): pass |
|
5b0fecd2eba0
#5723: Improve json tests to be executed with and without accelerations.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
66348
diff
changeset
|
23 class TestCDump(TestDump, CTest): pass |
