diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-15 12:01:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-15 12:01:08 (GMT) |
commit | 6545256df93ba54f811206107274cfa5a6d76b86 (patch) | |
tree | a1f5d782ddb4518b5ebe4039037ca26971b8b54e /Lib/test/pickletester.py | |
parent | 2ae4ad7ca49f2b80a02cbf7ea76d52c615bfedb3 (diff) | |
download | cpython-6545256df93ba54f811206107274cfa5a6d76b86.zip cpython-6545256df93ba54f811206107274cfa5a6d76b86.tar.gz cpython-6545256df93ba54f811206107274cfa5a6d76b86.tar.bz2 |
bpo-32032: Test both implementations of module-level pickle API. (#4401)
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r-- | Lib/test/pickletester.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py index 296faf0..243bc94 100644 --- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -2534,7 +2534,7 @@ class AbstractPickleModuleTests(unittest.TestCase): f = open(TESTFN, "wb") try: f.close() - self.assertRaises(ValueError, pickle.dump, 123, f) + self.assertRaises(ValueError, self.dump, 123, f) finally: os.remove(TESTFN) @@ -2543,16 +2543,16 @@ class AbstractPickleModuleTests(unittest.TestCase): f = open(TESTFN, "wb") try: f.close() - self.assertRaises(ValueError, pickle.dump, 123, f) + self.assertRaises(ValueError, self.dump, 123, f) finally: os.remove(TESTFN) def test_load_from_and_dump_to_file(self): stream = io.BytesIO() data = [123, {}, 124] - pickle.dump(data, stream) + self.dump(data, stream) stream.seek(0) - unpickled = pickle.load(stream) + unpickled = self.load(stream) self.assertEqual(unpickled, data) def test_highest_protocol(self): @@ -2562,20 +2562,20 @@ class AbstractPickleModuleTests(unittest.TestCase): def test_callapi(self): f = io.BytesIO() # With and without keyword arguments - pickle.dump(123, f, -1) - pickle.dump(123, file=f, protocol=-1) - pickle.dumps(123, -1) - pickle.dumps(123, protocol=-1) - pickle.Pickler(f, -1) - pickle.Pickler(f, protocol=-1) + self.dump(123, f, -1) + self.dump(123, file=f, protocol=-1) + self.dumps(123, -1) + self.dumps(123, protocol=-1) + self.Pickler(f, -1) + self.Pickler(f, protocol=-1) def test_bad_init(self): # Test issue3664 (pickle can segfault from a badly initialized Pickler). # Override initialization without calling __init__() of the superclass. - class BadPickler(pickle.Pickler): + class BadPickler(self.Pickler): def __init__(self): pass - class BadUnpickler(pickle.Unpickler): + class BadUnpickler(self.Unpickler): def __init__(self): pass self.assertRaises(pickle.PicklingError, BadPickler().dump, 0) |