Skip to content

Commit e30fd55

Browse files
mitarilevkivskyi
authored andcommitted
Make sure copy and deepcopy are returning same class (#460)
This should hold on Python 3.3 and newer (it does not hold on 3.2 and 2.7). From documentation: It does "copy" functions and classes (shallow and deeply), by returning the original object unchanged; this is compatible with the way these are treated by the pickle module.
1 parent 4e7c4b6 commit e30fd55

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/test_typing.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,13 @@ class Node(Generic[T]): ...
10691069
for t in things + [Any]:
10701070
self.assertEqual(t, copy(t))
10711071
self.assertEqual(t, deepcopy(t))
1072+
if sys.version_info >= (3, 3):
1073+
# From copy module documentation:
1074+
# It does "copy" functions and classes (shallow and deeply), by returning
1075+
# the original object unchanged; this is compatible with the way these
1076+
# are treated by the pickle module.
1077+
self.assertTrue(t is copy(t))
1078+
self.assertTrue(t is deepcopy(t))
10721079

10731080
def test_weakref_all(self):
10741081
T = TypeVar('T')

0 commit comments

Comments
 (0)