Skip to content

Commit 89d7d3e

Browse files
miss-islingtondslavicektomasr8
authored
[3.13] improve test_copy_reduce and test_deepcopy_reduce coverage (GH-154182) (#155794)
improve test_copy_reduce and test_deepcopy_reduce coverage (GH-154182) * improve test_copy_reduce and test_deepcopy_reduce coverage * add assert __reduce_ex__ not called * change reduce params in test copy and deepcopy reduce_ex * change reduce_ex params in test copy and deepcopy reduce --------- (cherry picked from commit 4af81d9) Co-authored-by: David <slavicek.david29@gmail.com> Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
1 parent 8e85d73 commit 89d7d3e

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Lib/test/test_copy.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class C(object):
6060
def __reduce_ex__(self, proto):
6161
c.append(1)
6262
return ""
63-
def __reduce__(self):
63+
def __reduce__(*args):
6464
self.fail("shouldn't call this")
6565
c = []
6666
x = C()
@@ -70,9 +70,15 @@ def __reduce__(self):
7070

7171
def test_copy_reduce(self):
7272
class C(object):
73+
def __reduce_ex__(*args):
74+
self.fail("shouldn't call this")
7375
def __reduce__(self):
7476
c.append(1)
7577
return ""
78+
def __getattribute__(self, name):
79+
if name == "__reduce_ex__":
80+
raise AttributeError(name)
81+
return object.__getattribute__(self, name)
7682
c = []
7783
x = C()
7884
y = copy.copy(x)
@@ -323,7 +329,7 @@ class C(object):
323329
def __reduce_ex__(self, proto):
324330
c.append(1)
325331
return ""
326-
def __reduce__(self):
332+
def __reduce__(*args):
327333
self.fail("shouldn't call this")
328334
c = []
329335
x = C()
@@ -333,9 +339,15 @@ def __reduce__(self):
333339

334340
def test_deepcopy_reduce(self):
335341
class C(object):
342+
def __reduce_ex__(*args):
343+
self.fail("shouldn't call this")
336344
def __reduce__(self):
337345
c.append(1)
338346
return ""
347+
def __getattribute__(self, name):
348+
if name == "__reduce_ex__":
349+
raise AttributeError(name)
350+
return object.__getattribute__(self, name)
339351
c = []
340352
x = C()
341353
y = copy.deepcopy(x)

0 commit comments

Comments
 (0)