Skip to content

Commit 974532e

Browse files
cmaloneyAA-Turner
andauthored
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>
1 parent 7274d07 commit 974532e

File tree

9 files changed

+28
-21
lines changed

9 files changed

+28
-21
lines changed

Lib/test/libregrtest/findtests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"test_future_stmt",
2525
"test_gdb",
2626
"test_inspect",
27+
"test_io",
2728
"test_pydoc",
2829
"test_multiprocessing_fork",
2930
"test_multiprocessing_forkserver",

Lib/test/test_io/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
"""Tests for the io module and its implementations (_io and _pyio)
2+
3+
Tests are split across multiple files to increase
4+
parallelism and focus on specific implementation pieces.
5+
6+
* test_io
7+
* test_bufferedio - tests file buffering
8+
* test_memoryio - tests BytesIO and StringIO
9+
* test_fileio - tests FileIO
10+
* test_file - tests the file interface
11+
* test_general - tests everything else in the io module
12+
* test_univnewlines - tests universal newline support
13+
* test_largefile - tests operations on a file greater than 2**32 bytes
14+
(only enabled with -ulargefile)
15+
* test_free_threading/test_io - tests thread safety of io objects
16+
17+
.. attention::
18+
When writing tests for io, it's important to test both the C and Python
19+
implementations. This is usually done by writing a base test that refers to
20+
the type it is testing as an attribute. Then it provides custom subclasses to
21+
test both implementations. This directory contains lots of examples.
22+
"""
23+
124
import os
225
from test.support import load_package_tests
326

File renamed without changes.
File renamed without changes.
File renamed without changes.

Lib/test/test_io/test_general.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
1-
"""Unit tests for the io module."""
2-
3-
# Tests of io are scattered over the test suite:
4-
# * test_bufio - tests file buffering
5-
# * test_memoryio - tests BytesIO and StringIO
6-
# * test_fileio - tests FileIO
7-
# * test_file - tests the file interface
8-
# * test_io.test_general - tests everything else in the io module
9-
# * test_univnewlines - tests universal newline support
10-
# * test_largefile - tests operations on a file greater than 2**32 bytes
11-
# (only enabled with -ulargefile)
12-
# * test_free_threading/test_io - tests thread safety of io objects
13-
14-
################################################################################
15-
# ATTENTION TEST WRITERS!!!
16-
################################################################################
17-
# When writing tests for io, it's important to test both the C and Python
18-
# implementations. This is usually done by writing a base test that refers to
19-
# the type it is testing as an attribute. Then it provides custom subclasses to
20-
# test both implementations. This file has lots of examples.
21-
################################################################################
1+
"""General tests for the io module.
2+
3+
New tests should go in more specific modules; see test_io/__init__.py
4+
"""
225

236
import abc
247
import array
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)