| OLD | NEW |
|---|---|
| 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 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 = protocols[-1] + 1 # a future protocol | 588 oob = list(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 Loading... | |
| 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() |
| OLD | NEW |