summaryrefslogtreecommitdiff
path: root/Lib/test/test_copy.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_copy.py')
-rw-r--r--Lib/test/test_copy.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index c97d54d749..35ce46a523 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -2,6 +2,7 @@
import sys
import copy
+import copy_reg
import unittest
from test import test_support
@@ -32,6 +33,19 @@ class TestCopy(unittest.TestCase):
self.assertEqual(y.__class__, x.__class__)
self.assertEqual(y.foo, x.foo)
+ def test_copy_registry(self):
+ class C(object):
+ def __new__(cls, foo):
+ obj = object.__new__(cls)
+ obj.foo = foo
+ return obj
+ def pickle_C(obj):
+ return (C, (obj.foo,))
+ x = C(42)
+ self.assertRaises(TypeError, copy.copy, x)
+ copy_reg.pickle(C, pickle_C, C)
+ y = copy.copy(x)
+
def test_copy_reduce(self):
class C(object):
def __reduce__(self):
@@ -182,6 +196,19 @@ class TestCopy(unittest.TestCase):
self.assertEqual(y.__class__, x.__class__)
self.assertEqual(y.foo, x.foo)
+ def test_deepcopy_registry(self):
+ class C(object):
+ def __new__(cls, foo):
+ obj = object.__new__(cls)
+ obj.foo = foo
+ return obj
+ def pickle_C(obj):
+ return (C, (obj.foo,))
+ x = C(42)
+ self.assertRaises(TypeError, copy.deepcopy, x)
+ copy_reg.pickle(C, pickle_C, C)
+ y = copy.deepcopy(x)
+
def test_deepcopy_reduce(self):
class C(object):
def __reduce__(self):