diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-07-03 18:45:33 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-07-03 18:45:33 (GMT) |
| commit | 92843e3c144b3a7a78e1c6b11ec85f06227c42ab (patch) | |
| tree | a26f3984954f688b5a4da6710f5077b941f42961 /Lib/test/test_marshal.py | |
| parent | 774f83cda4df80ea259d836624a7c3d68ec66495 (diff) | |
| parent | 37d72b716488250c0128c53601a0f3fab5ea7faf (diff) | |
| download | cpython-92843e3c144b3a7a78e1c6b11ec85f06227c42ab.zip cpython-92843e3c144b3a7a78e1c6b11ec85f06227c42ab.tar.gz cpython-92843e3c144b3a7a78e1c6b11ec85f06227c42ab.tar.bz2 | |
merge heads
Diffstat (limited to 'Lib/test/test_marshal.py')
| -rw-r--r-- | Lib/test/test_marshal.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py index 8a5590a..dec8129 100644 --- a/Lib/test/test_marshal.py +++ b/Lib/test/test_marshal.py @@ -228,6 +228,30 @@ class BugsTestCase(unittest.TestCase): invalid_string = b'l\x02\x00\x00\x00\x00\x00\x00\x00' self.assertRaises(ValueError, marshal.loads, invalid_string) + def test_multiple_dumps_and_loads(self): + # Issue 12291: marshal.load() should be callable multiple times + # with interleaved data written by non-marshal code + # Adapted from a patch by Engelbert Gruber. + data = (1, 'abc', b'def', 1.0, (2, 'a', ['b', b'c'])) + for interleaved in (b'', b'0123'): + ilen = len(interleaved) + positions = [] + try: + with open(support.TESTFN, 'wb') as f: + for d in data: + marshal.dump(d, f) + if ilen: + f.write(interleaved) + positions.append(f.tell()) + with open(support.TESTFN, 'rb') as f: + for i, d in enumerate(data): + self.assertEqual(d, marshal.load(f)) + if ilen: + f.read(ilen) + self.assertEqual(positions[i], f.tell()) + finally: + support.unlink(support.TESTFN) + def test_main(): support.run_unittest(IntTestCase, |
