@@ -95,24 +95,67 @@ def f():
95
95
pass
96
96
class WithMetaclass (metaclass = abc .ABCMeta ):
97
97
pass
98
- tests = [None , 42 , 2 ** 100 , 3.14 , True , False , 1j ,
98
+ tests = [None , ..., NotImplemented ,
99
+ 42 , 2 ** 100 , 3.14 , True , False , 1j ,
99
100
"hello" , "hello\u1234 " , f .__code__ ,
100
- b"world" , bytes (range (256 )),
101
- NewStyle , range ( 10 ), Classic , max , WithMetaclass ]
101
+ b"world" , bytes (range (256 )), range ( 10 ),
102
+ NewStyle , Classic , max , WithMetaclass ]
102
103
for x in tests :
103
104
self .assertIs (copy .copy (x ), x )
104
105
105
106
def test_copy_list (self ):
106
107
x = [1 , 2 , 3 ]
107
- self .assertEqual (copy .copy (x ), x )
108
+ y = copy .copy (x )
109
+ self .assertEqual (y , x )
110
+ self .assertIsNot (y , x )
111
+ x = []
112
+ y = copy .copy (x )
113
+ self .assertEqual (y , x )
114
+ self .assertIsNot (y , x )
108
115
109
116
def test_copy_tuple (self ):
110
117
x = (1 , 2 , 3 )
111
- self .assertEqual (copy .copy (x ), x )
118
+ self .assertIs (copy .copy (x ), x )
119
+ x = ()
120
+ self .assertIs (copy .copy (x ), x )
121
+ x = (1 , 2 , 3 , [])
122
+ self .assertIs (copy .copy (x ), x )
112
123
113
124
def test_copy_dict (self ):
114
125
x = {"foo" : 1 , "bar" : 2 }
115
- self .assertEqual (copy .copy (x ), x )
126
+ y = copy .copy (x )
127
+ self .assertEqual (y , x )
128
+ self .assertIsNot (y , x )
129
+ x = {}
130
+ y = copy .copy (x )
131
+ self .assertEqual (y , x )
132
+ self .assertIsNot (y , x )
133
+
134
+ def test_copy_set (self ):
135
+ x = {1 , 2 , 3 }
136
+ y = copy .copy (x )
137
+ self .assertEqual (y , x )
138
+ self .assertIsNot (y , x )
139
+ x = set ()
140
+ y = copy .copy (x )
141
+ self .assertEqual (y , x )
142
+ self .assertIsNot (y , x )
143
+
144
+ def test_copy_frozenset (self ):
145
+ x = frozenset ({1 , 2 , 3 })
146
+ self .assertIs (copy .copy (x ), x )
147
+ x = frozenset ()
148
+ self .assertIs (copy .copy (x ), x )
149
+
150
+ def test_copy_bytearray (self ):
151
+ x = bytearray (b'abc' )
152
+ y = copy .copy (x )
153
+ self .assertEqual (y , x )
154
+ self .assertIsNot (y , x )
155
+ x = bytearray ()
156
+ y = copy .copy (x )
157
+ self .assertEqual (y , x )
158
+ self .assertIsNot (y , x )
116
159
117
160
def test_copy_inst_vanilla (self ):
118
161
class C :
0 commit comments