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_memoryview.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_memoryview.py')
-rw-r--r-- | Lib/test/test_memoryview.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py index 4407af8..4269858 100644 --- a/Lib/test/test_memoryview.py +++ b/Lib/test/test_memoryview.py @@ -12,6 +12,7 @@ from test import test_support import io import copy import pickle +import warnings class AbstractMemoryTests: @@ -359,15 +360,20 @@ class BytesMemorySliceSliceTest(unittest.TestCase, class OtherTest(unittest.TestCase): def test_copy(self): m = memoryview(b'abc') - with self.assertRaises(TypeError): + with self.assertRaises(TypeError), warnings.catch_warnings(): + warnings.filterwarnings('ignore', ".*memoryview", DeprecationWarning) copy.copy(m) - # See issue #22995 - ## def test_pickle(self): - ## m = memoryview(b'abc') - ## for proto in range(pickle.HIGHEST_PROTOCOL + 1): - ## with self.assertRaises(TypeError): - ## pickle.dumps(m, proto) + @test_support.cpython_only + def test_pickle(self): + m = memoryview(b'abc') + for proto in range(2): + with self.assertRaises(TypeError): + pickle.dumps(m, proto) + with test_support.check_py3k_warnings( + (".*memoryview", DeprecationWarning)): + pickle.dumps(m, 2) + def test_main(): |