Skip to content

Conversation

dbXD320
Copy link
Contributor

@dbXD320 dbXD320 commented Sep 6, 2025

This PR updates three tests in Lib/test/list_tests.py (CommonTest) to consistently use self.type2test instead of directly constructing a list (or []).

test_getitem_error

test_setitem_error

test_constructor_exception_handling

Previously, these tests only applied to the builtin list, and skipped other list-like classes (such as collections.UserList) that reuse CommonTest.

By switching to self.type2test, the tests now correctly apply to all list-like types under test, ensuring consistency across the test suite.

fixes #138584

@dbXD320 dbXD320 requested a review from picnixz September 6, 2025 18:16
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked the usage of this class but I think we can just assume that we'll only be using it for list and userlist so it's fine to keep the error message as is. If it needs to be changed later, we'll just refactor the tests nicely.

@picnixz picnixz merged commit d7b9ea5 into python:main Sep 7, 2025
47 checks passed
@picnixz picnixz added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Sep 7, 2025
@miss-islington-app
Copy link

Thanks @dbXD320 for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @dbXD320 for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 7, 2025
…ythonGH-138590)

Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------
(cherry picked from commit d7b9ea5)

Co-authored-by: dbXD320 <[email protected]>
Co-authored-by: Devansh Baghla <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 7, 2025
…ythonGH-138590)

Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------
(cherry picked from commit d7b9ea5)

Co-authored-by: dbXD320 <[email protected]>
Co-authored-by: Devansh Baghla <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Sep 7, 2025

GH-138611 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 7, 2025
@bedevere-app
Copy link

bedevere-app bot commented Sep 7, 2025

GH-138612 is a backport of this pull request to the 3.14 branch.

@picnixz
Copy link
Member

picnixz commented Sep 7, 2025

For the sake of reducing the diff and correctly improve test coverage, I'm going to backport this.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Sep 7, 2025
@dbXD320
Copy link
Contributor Author

dbXD320 commented Sep 7, 2025

@serhiy-storchaka @picnixz Thank you for the review and guidance, I really appreciate it!

@picnixz
Copy link
Member

picnixz commented Sep 7, 2025

Thank you for the fix

picnixz pushed a commit that referenced this pull request Sep 7, 2025
…H-138590) (#138611)

gh-138584: Increase test coverage for `collections.UserList` (GH-138590)

Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------
(cherry picked from commit d7b9ea5)

Co-authored-by: dbXD320 <[email protected]>
Co-authored-by: Devansh Baghla <[email protected]>
hugovk pushed a commit that referenced this pull request Sep 7, 2025
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
…ython#138590)

Some common tests in `test.list_tests.CommonTest` explicitly tested `list`
instead of testing the underlying list-like type defined in `type2test`.

---------

Co-authored-by: Devansh Baghla <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lib/tests/list_tests.py is missing type2test in a few methods

4 participants