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

Delta Between Two Patch Sets: Lib/test/pickletester.py

Issue 602: range: lean and mean (Closed) SVN Base: http://svn.python.org/view/*checkout*/python/branches/py3k/
Left Patch Set: __len__ is back! Created 1 year, 7 months ago
Right Patch Set: address more concerns Created 1 year, 7 months ago , Downloaded from: http://bugs.python.org/file10183/range_lean_and_mean5.patch
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 import unittest 1 import unittest
2 import pickle 2 import pickle
3 import pickletools 3 import pickletools
4 import copy_reg 4 import copy_reg
5 5
6 from test.test_support import TestFailed, TESTFN, run_with_locale 6 from test.test_support import TestFailed, TESTFN, run_with_locale
7 7
8 from pickle import bytes_types 8 from pickle import bytes_types
9 9
10 # Tests that try a number of pickle protocols should have a 10 # Tests that try a number of pickle protocols should have a
11 # for proto in protocols: 11 # for proto in protocols:
12 # kind of outer loop. 12 # kind of outer loop.
13 protocols = range(pickle.HIGHEST_PROTOCOL + 1) 13 protocols = list(range(pickle.HIGHEST_PROTOCOL + 1))
14 14
15 15
16 # Return True if opcode code appears in the pickle, else False. 16 # Return True if opcode code appears in the pickle, else False.
17 def opcode_in_pickle(code, pickle): 17 def opcode_in_pickle(code, pickle):
18 for op, dummy, dummy in pickletools.genops(pickle): 18 for op, dummy, dummy in pickletools.genops(pickle):
19 if op.code == code.decode("latin-1"): 19 if op.code == code.decode("latin-1"):
20 return True 20 return True
21 return False 21 return False
22 22
23 # Return the number of times opcode code appears in pickle. 23 # Return the number of times opcode code appears in pickle.
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 578
579 def test_proto(self): 579 def test_proto(self):
580 build_none = pickle.NONE + pickle.STOP 580 build_none = pickle.NONE + pickle.STOP
581 for proto in protocols: 581 for proto in protocols:
582 expected = build_none 582 expected = build_none
583 if proto >= 2: 583 if proto >= 2:
584 expected = pickle.PROTO + bytes([proto]) + expected 584 expected = pickle.PROTO + bytes([proto]) + expected
585 p = self.dumps(None, proto) 585 p = self.dumps(None, proto)
586 self.assertEqual(p, expected) 586 self.assertEqual(p, expected)
587 587
588 oob = list(protocols)[-1] + 1 # a future protocol 588 oob = protocols[-1] + 1 # a future protocol
Alexandre Vassalotti 2008/05/03 07:12:01 The list() call should be moved to line 13, where
589 badpickle = pickle.PROTO + bytes([oob]) + build_none 589 badpickle = pickle.PROTO + bytes([oob]) + build_none
590 try: 590 try:
591 self.loads(badpickle) 591 self.loads(badpickle)
592 except ValueError as detail: 592 except ValueError as detail:
593 self.failUnless(str(detail).startswith( 593 self.failUnless(str(detail).startswith(
594 "unsupported pickle protocol")) 594 "unsupported pickle protocol"))
595 else: 595 else:
596 self.fail("expected bad protocol number to raise ValueError") 596 self.fail("expected bad protocol number to raise ValueError")
597 597
598 def test_long1(self): 598 def test_long1(self):
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 for j in range(0, len(p), 20): 1028 for j in range(0, len(p), 20):
1029 b = bytes(p[j:j+20]) 1029 b = bytes(p[j:j+20])
1030 print(" {0!r}".format(b)) 1030 print(" {0!r}".format(b))
1031 print(")") 1031 print(")")
1032 print() 1032 print()
1033 print("# Disassembly of DATA{0}".format(i)) 1033 print("# Disassembly of DATA{0}".format(i))
1034 print("DATA{0}_DIS = \"\"\"\\".format(i)) 1034 print("DATA{0}_DIS = \"\"\"\\".format(i))
1035 dis(p) 1035 dis(p)
1036 print("\"\"\"") 1036 print("\"\"\"")
1037 print() 1037 print()
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r497