Skip to content

Conversation

@cmaloney
Copy link
Contributor

@cmaloney cmaloney commented Sep 2, 2025

Reduce what happens in load_tests so that the next change, moving the Buffered* tests to test_bufferdio is purely mechanical movement and updating imports.

This adds two classes, one per I/O implementation, to act as dispatch to the implementation-specific mocks as well as module members. Previously the mappings CTestCase and PyTestCase provide were injected directly during load_tests.

CTestCase and PyTestCase inherit from unittest.TestCase so when the split happens default test discovery will work for the classes in test_bufferedio. test_general keeps a manual test list for this refactoring; some of the tests (ex. ProtocolsTest) aren't currently run and fixing that + helpers to not be picked up as tests is out of my current scope.

CTestCase and PyTestCase have an io class member which points to the implementation meaning that can be removed from individual test cases which now inherit from them.

Tested locally with ./python -m test test_io -uall,walltime,largefile,extralargefile -M16G -j8 -v


  1. Could this get skip news as its a test-only change?
  2. Could buildbots be run against this? Worried there are lots of platform-specific cases in these test cases and would rather proactively debug/fix than reactively (Ex. 4 tests are skipped for me on my 64 bit Linux box because: "only run in 32-bit address space" and "only when utf-8 mode is disabled")

Reduce what happens in `load_tests` so that the next change,
moving the `Buffered*` tests to `test_bufferdio` is purely mechanical
movement and updating imports.

This adds two classes, one per I/O implementation, to act as dispatch to
the implementation-specific mocks as well as module members. Previously
the mappings CTestCase and PyTestCase provide were injected directly
during `load_tests`.

CTestCase and PyTestCase inherit from `unittest.TestCase` so when the
split happens default test discovery will work for the classes in
`test_bufferedio`. `test_general` keeps a manual test list for this
refactoring; some of the tests (ex. `ProtocolsTest`) aren't currently
run and fixing that + helpers to not be picked up is out of my current
scope.

CTestCase and PyTestCase have an `io` class member which points to the
implementation meaning that can be removed from individual test cases
which now inherit from them.
This code is picking up `MockRawIO` which is defined globally in the
module but these should use the mock specific to the I/O implementation
being tested.
@cmaloney
Copy link
Contributor Author

cmaloney commented Sep 2, 2025

Added another commit to fix a gh-133982 issue I found while testing out the split. There are a number of test classes defined inside specific test cases that were referring to MockRawIO directly rather than self.MockRawIO

@vstinner vstinner added skip news 🔨 test-with-buildbots Test PR w/ buildbots; report in status section labels Sep 2, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @vstinner for commit 751788f 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F138366%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 2, 2025
@vstinner
Copy link
Member

vstinner commented Sep 2, 2025

Could this get skip news as its a test-only change?

Done.

Could buildbots be run against this?

Done.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM.

./python -m test test_io --list-cases output is unchanged with this change.

Remove unnecessary pass through self

Co-authored-by: Victor Stinner <[email protected]>
@cmaloney
Copy link
Contributor Author

cmaloney commented Sep 3, 2025

One bot failure buildbot/AMD64 Windows 11 Refleaks PR in test_remote_pdb which looks independent (Code this PR doesn’t touch), so I think this is good to go once the suggestion application finishes in Github actions bots

@vstinner vstinner merged commit 6dd21e9 into python:main Sep 3, 2025
43 checks passed
@vstinner
Copy link
Member

vstinner commented Sep 3, 2025

Merged, thanks.

@cmaloney cmaloney deleted the test_io_simplify_load_tests branch September 3, 2025 16:49
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
…ython#138366)

Reduce what happens in `load_tests` so that the next change,
moving the `Buffered*` tests to `test_bufferdio` is purely mechanical
movement and updating imports.

This adds two classes, one per I/O implementation, to act as dispatch to
the implementation-specific mocks as well as module members. Previously
the mappings CTestCase and PyTestCase provide were injected directly
during `load_tests`.

CTestCase and PyTestCase inherit from `unittest.TestCase` so when the
split happens default test discovery will work for the classes in
`test_bufferedio`. `test_general` keeps a manual test list for this
refactoring; some of the tests (ex. `ProtocolsTest`) aren't currently
run and fixing that + helpers to not be picked up is out of my current
scope.

CTestCase and PyTestCase have an `io` class member which points to the
implementation meaning that can be removed from individual test cases
which now inherit from them.

This code is picking up `MockRawIO` which is defined globally in the
module but these should use the mock specific to the I/O implementation
being tested.

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

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants