Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Side by Side Diff: Lib/test/test_marshal.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_mailbox.py ('k') | Lib/test/test_minidom.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 from test import support 3 from test import support
4 import marshal 4 import marshal
5 import sys 5 import sys
6 import unittest 6 import unittest
7 import os 7 import os
8 import types 8 import types
9 9
10 class HelperMixin: 10 class HelperMixin:
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 # internal buffer; this test ensures that the new code is exercised. 220 # internal buffer; this test ensures that the new code is exercised.
221 def test_large_marshal(self): 221 def test_large_marshal(self):
222 size = int(1e6) 222 size = int(1e6)
223 testString = 'abc' * size 223 testString = 'abc' * size
224 marshal.dumps(testString) 224 marshal.dumps(testString)
225 225
226 def test_invalid_longs(self): 226 def test_invalid_longs(self):
227 # Issue #7019: marshal.loads shouldn't produce unnormalized PyLongs 227 # Issue #7019: marshal.loads shouldn't produce unnormalized PyLongs
228 invalid_string = b'l\x02\x00\x00\x00\x00\x00\x00\x00' 228 invalid_string = b'l\x02\x00\x00\x00\x00\x00\x00\x00'
229 self.assertRaises(ValueError, marshal.loads, invalid_string) 229 self.assertRaises(ValueError, marshal.loads, invalid_string)
230
231 def test_multiple_dumps_and_loads(self):
232 # Issue 12291: marshal.load() should be callable multiple times
233 # with interleaved data written by non-marshal code
234 # Adapted from a patch by Engelbert Gruber.
235 data = (1, 'abc', b'def', 1.0, (2, 'a', ['b', b'c']))
236 for interleaved in (b'', b'0123'):
237 ilen = len(interleaved)
238 positions = []
239 try:
240 with open(support.TESTFN, 'wb') as f:
241 for d in data:
242 marshal.dump(d, f)
243 if ilen:
244 f.write(interleaved)
245 positions.append(f.tell())
246 with open(support.TESTFN, 'rb') as f:
247 for i, d in enumerate(data):
248 self.assertEqual(d, marshal.load(f))
249 if ilen:
250 f.read(ilen)
251 self.assertEqual(positions[i], f.tell())
252 finally:
253 support.unlink(support.TESTFN)
254 230
255 231
256 def test_main(): 232 def test_main():
257 support.run_unittest(IntTestCase, 233 support.run_unittest(IntTestCase,
258 FloatTestCase, 234 FloatTestCase,
259 StringTestCase, 235 StringTestCase,
260 CodeTestCase, 236 CodeTestCase,
261 ContainerTestCase, 237 ContainerTestCase,
262 ExceptionTestCase, 238 ExceptionTestCase,
263 BugsTestCase) 239 BugsTestCase)
264 240
265 if __name__ == "__main__": 241 if __name__ == "__main__":
266 test_main() 242 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_mailbox.py ('k') | Lib/test/test_minidom.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+