]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-138013: Remove `test_io` load_tests namespace manipulation (#138366)
authorCody Maloney <cmaloney@users.noreply.github.com>
Wed, 3 Sep 2025 09:49:59 +0000 (02:49 -0700)
committerGitHub <noreply@github.com>
Wed, 3 Sep 2025 09:49:59 +0000 (11:49 +0200)
commit6dd21e9f56cfc9eb5a5c21382e3241e700d86aa6
treef2faa9cdd8cd54b14f16762d79cce99e393b9f6e
parent974532e75888a82adbaa11c832fe67c132832b65
gh-138013: Remove `test_io` load_tests namespace manipulation (#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 <vstinner@python.org>
Lib/test/test_io/test_general.py