@@ -51,6 +51,9 @@ def pickle_C(obj):
51
51
self .assertRaises (TypeError , copy .copy , x )
52
52
copyreg .pickle (C , pickle_C , C )
53
53
y = copy .copy (x )
54
+ self .assertIsNot (x , y )
55
+ self .assertEqual (type (y ), C )
56
+ self .assertEqual (y .foo , x .foo )
54
57
55
58
def test_copy_reduce_ex (self ):
56
59
class C (object ):
@@ -315,6 +318,9 @@ def pickle_C(obj):
315
318
self .assertRaises (TypeError , copy .deepcopy , x )
316
319
copyreg .pickle (C , pickle_C , C )
317
320
y = copy .deepcopy (x )
321
+ self .assertIsNot (x , y )
322
+ self .assertEqual (type (y ), C )
323
+ self .assertEqual (y .foo , x .foo )
318
324
319
325
def test_deepcopy_reduce_ex (self ):
320
326
class C (object ):
@@ -351,17 +357,15 @@ def __getattribute__(self, name):
351
357
352
358
# Type-specific _deepcopy_xxx() methods
353
359
354
- # TODO: RUSTPYTHON
355
- @unittest .expectedFailure
356
360
def test_deepcopy_atomic (self ):
357
361
class Classic :
358
362
pass
359
363
class NewStyle (object ):
360
364
pass
361
365
def f ():
362
366
pass
363
- tests = [None , 42 , 2 ** 100 , 3.14 , True , False , 1j ,
364
- "hello" , "hello\u1234 " , f .__code__ ,
367
+ tests = [None , ..., NotImplemented , 42 , 2 ** 100 , 3.14 , True , False , 1j ,
368
+ b"bytes" , "hello" , "hello\u1234 " , f .__code__ ,
365
369
NewStyle , range (10 ), Classic , max , property ()]
366
370
for x in tests :
367
371
self .assertIs (copy .deepcopy (x ), x )
@@ -684,6 +688,28 @@ def __eq__(self, other):
684
688
self .assertIsNot (x , y )
685
689
self .assertIsNot (x ["foo" ], y ["foo" ])
686
690
691
+ def test_reduce_6tuple (self ):
692
+ def state_setter (* args , ** kwargs ):
693
+ self .fail ("shouldn't call this" )
694
+ class C :
695
+ def __reduce__ (self ):
696
+ return C , (), self .__dict__ , None , None , state_setter
697
+ x = C ()
698
+ with self .assertRaises (TypeError ):
699
+ copy .copy (x )
700
+ with self .assertRaises (TypeError ):
701
+ copy .deepcopy (x )
702
+
703
+ def test_reduce_6tuple_none (self ):
704
+ class C :
705
+ def __reduce__ (self ):
706
+ return C , (), self .__dict__ , None , None , None
707
+ x = C ()
708
+ with self .assertRaises (TypeError ):
709
+ copy .copy (x )
710
+ with self .assertRaises (TypeError ):
711
+ copy .deepcopy (x )
712
+
687
713
def test_copy_slots (self ):
688
714
class C (object ):
689
715
__slots__ = ["foo" ]
0 commit comments