Commit graph

10 commits

Author SHA1 Message Date
Cody Maloney
ce23eeaa2b
gh-138013: Split BufferedIO tests from test_io.test_general (#139454)
The last remaining set of tests to split out that are focused on one
specific implementation portion (`bufferedio.c`).

test_io.test_general is now largely tests around `io.open` and module
properties (ex. pickling, class hierarchy, module members, etc).

This closes #138013.
2025-10-01 09:06:26 +02:00
Cody Maloney
f752fde452
gh-138013: Split TextIO tests from test_io.test_general (#139173)
gh-138013: Split TextIO tests from test_general

These tests take 1.3 seconds on my dev machine, match fairly closely
with testing `textio.c` implementation only.
2025-09-30 17:37:15 +02:00
Cody Maloney
69c6b438e8
gh-138013: Split SignalsTest from test_io.test_general (#139079)
Increase parallelism by splitting out `SignalsTest` from test_general.
`SignalsTest` takes 24.2 seconds on my dev machine when fully enabled
making it the largest part of `test_io`. Code move done via copy/paste
then tweak imports.

After splitting `test_io.test_general` is down to 10.1 seconds on my dev
box with all parts enabled.
2025-09-19 18:21:50 +00:00
Cody Maloney
db68bfc771
gh-138720: Make Buffered closed check match flush (GH-138724)
In `_io__Buffered_flush_impl` the macro `CHECK_CLOSED` is used to check
the `buffered*` is in a good state to be flushed. That differs slightly
from `buffered_closed`.

In some cases, that difference would result in `close()` thinking the
file needed to be flushed and closed while `flush()` thought the file
was already closed.

This could happen during GC and would result in an unraisable exception.
2025-09-18 12:02:29 +02:00
Cody Maloney
ed75160b73
gh-138013: Remove load_tests in test_io.test_general (#138771)
Rely on default test discovery.

Validation:
```bash
 # Run before commit
./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > old_cases.txt
 # Run after commit
./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > new_cases.txt

diff new_cases.txt old_cases.
 # <outputs no changes in case list>
```
2025-09-16 10:37:28 +02:00
Cody Maloney
101172486f
gh-138013: Move I/O test infrastructre to test_io.utils (#138475)
This moves test support code to `test_io.utils` via copy/paste
code movement then adjusts imports as needed
(remove unneded + add all required).
2025-09-11 12:45:30 +02:00
Cody Maloney
6dd21e9f56
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>
2025-09-03 11:49:59 +02:00
Cody Maloney
974532e758
gh-138013: Move I/O tests to test_io (#138365)
Centralize `io` tests into the `test_io` module so they are easier to
find and work on. This will make it easier to split `test_general` which
takes 30+ seconds in a debug build on my machine.

This renames `test_bufio` to be `test_bufferedio` so that it matches
the implementation file name (`bufferedio.c`).

Validation performed:
Tests are run in parallel after change:

```bash
./python.exe -m test test_io  -uall,largefile,extralargefile -M12G -j8
```

Docstring reformat in `test_io/__init__.py` looks reasonable:

```python
>>> import test.test_io
>>> help(test.test_io)
```

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2025-09-03 11:37:06 +02:00
Sebastian Rittau
3f23888fd7
gh-127647: Fix and enable I/O protocol tests (#138369) 2025-09-02 06:45:29 -07:00
Cody Maloney
15e37ea6b7
gh-138013: Make `test.test_io` into a package (#138153) 2025-08-31 20:14:19 +01:00
Renamed from Lib/test/test_io.py (Browse further)