diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2017-08-02 08:33:33 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-02 08:33:33 (GMT) |
| commit | 3dd1ccbb0950b2b83713a495958c35d60b453fa9 (patch) | |
| tree | 03af89067ea8cc0eac8084d705e7481ce896a70f /Lib/test/test_buffer.py | |
| parent | 956902e5bc4b41fda79c6c1018c97355639cb245 (diff) | |
| download | cpython-3dd1ccbb0950b2b83713a495958c35d60b453fa9.zip cpython-3dd1ccbb0950b2b83713a495958c35d60b453fa9.tar.gz cpython-3dd1ccbb0950b2b83713a495958c35d60b453fa9.tar.bz2 | |
bpo-29902: Emit a Py3k deprecation warning when pickling or copying (#2823)
some builtin and extension objects that don't support pickling
explicitly and are pickled incorrectly by default (like memoryview or
staticmethod).
Diffstat (limited to 'Lib/test/test_buffer.py')
| -rw-r--r-- | Lib/test/test_buffer.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index de80d44..c7114cd 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -8,6 +8,7 @@ import copy import pickle import sys import unittest +import warnings from test import test_support class BufferTests(unittest.TestCase): @@ -39,15 +40,19 @@ class BufferTests(unittest.TestCase): def test_copy(self): buf = buffer(b'abc') - with self.assertRaises(TypeError): + with self.assertRaises(TypeError), warnings.catch_warnings(): + warnings.filterwarnings('ignore', ".*buffer", DeprecationWarning) copy.copy(buf) - # See issue #22995 - ## def test_pickle(self): - ## buf = buffer(b'abc') - ## for proto in range(pickle.HIGHEST_PROTOCOL + 1): - ## with self.assertRaises(TypeError): - ## pickle.dumps(buf, proto) + @test_support.cpython_only + def test_pickle(self): + buf = buffer(b'abc') + for proto in range(2): + with self.assertRaises(TypeError): + pickle.dumps(buf, proto) + with test_support.check_py3k_warnings( + (".*buffer", DeprecationWarning)): + pickle.dumps(buf, 2) def test_main(): |
