improve test_copy_reduce and test_deepcopy_reduce coverage#154182
improve test_copy_reduce and test_deepcopy_reduce coverage#154182dslavicek wants to merge 3 commits into
Conversation
|
Rather than modifying existing tests, could you create new tests for the |
Since the existing tests are named Maybe I gave the PR a confusing name and should have named it something like "Fix test_copy_reduce and "test_deepcopy_reduce". |
|
Ah I see, I didn't notice there was already a test for def __reduce_ex__(self):
self.fail("shouldn't call this") |
I don't think I can. The point is In the existing version of the test because no I want to make sure |
This should work no? Unless I'm missing something? class C(object):
def __reduce_ex__(self, proto):
self.fail("shouldn't call this")
def __reduce__(self):
c.append(1)
return ""
def __getattribute__(self, name):
if name == "__reduce_ex__":
raise AttributeError(name)
return object.__getattribute__(self, name)Also, unrelated, but the |
Sorry, I misunderstood. Of course I can add the |
|
Ah sorry, I wasn't clear about what I meant.. I'd just fix the |
I am unsure how to handle it. Should I just rename the parameter? What new name do you propose? Should I replace |
|
I think renaming the inner def __reduce_ex__(*args):
self.fail("shouldn't call this") |
Done :-) |
|
Also needs to be fixed in |
Line 94 in
copy()method and line 150 indeepcopy()method were not covered by tests. This happened because thereductor = getattr(x, "__reduce_ex__", None)at lines 88 and 144 took__reduce_ex__from theobjectclass which preventing reaching theelseblock where__reduce__is checked.This PR adds coverage for those two lines and by this increases branch coverage of the copy module to 100%.
printscreen of coverage check on main:
