Skip to content

improve test_copy_reduce and test_deepcopy_reduce coverage#154182

Open
dslavicek wants to merge 1 commit into
python:mainfrom
dslavicek:improve-copy-and-deepcopy-reduce-test-coverage2
Open

improve test_copy_reduce and test_deepcopy_reduce coverage#154182
dslavicek wants to merge 1 commit into
python:mainfrom
dslavicek:improve-copy-and-deepcopy-reduce-test-coverage2

Conversation

@dslavicek

Copy link
Copy Markdown
Contributor

Line 94 in copy() method and line 150 in deepcopy() method were not covered by tests. This happened because the reductor = getattr(x, "__reduce_ex__", None) at lines 88 and 144 took __reduce_ex__ from the object class which preventing reaching the else block 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:
image

@tomasr8

tomasr8 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Rather than modifying existing tests, could you create new tests for the __reduce__ case?

@dslavicek

Copy link
Copy Markdown
Contributor Author

Rather than modifying existing tests, could you create new tests for the __reduce__ case?

Since the existing tests are named test_copy_reduce and test_deepcopy_reduce it occured to me they are supposed to cover the __reduce__ case and there should be no new tests added for this.

Maybe I gave the PR a confusing name and should have named it something like "Fix test_copy_reduce and "test_deepcopy_reduce".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants