diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-15 04:32:04 -0800 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-15 14:32:04 +0200 |
commit | eb38367f20b05f2ad04a4833bceb369b5e78b1a3 (patch) | |
tree | f3fb87aa5b68db1b3cf97805adbc883a4a01bd06 /Lib/test/pickletester.py | |
parent | 42336def77f53861284336b3335098a1b9b8cab2 (diff) | |
download | cpython-git-eb38367f20b05f2ad04a4833bceb369b5e78b1a3.tar.gz |
bpo-32032: Test both implementations of module-level pickle API. (GH-4401) (#4403)
(cherry picked from commit 6545256df93ba54f811206107274cfa5a6d76b86)
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 5c83361027..a1c0bd726f 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) |