GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-138013: Move test.test_io to be a module by cmaloney · Pull Request #138153 · python/cpython

Conversation

@cmaloney

@cmaloney cmaloney commented Aug 26, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This sets up for having a test_io._support which contains the I/O mocks for sharing between multiple io module test files. Also starts a path for all the io module tests to live in a single module for simpler running rather than requiring knowledge of the list of io tests which lives in a comment in test_io.

Common test invocatoins (ex. python -m test test_io -uall -M8G and python -m test.test_io) run the same set of tests after this change as before.


I copied __init__.py and __main__.py from other python test sub directory instances; happy to tweak if needed.

It is possible to split out the Buffered I/O tests without moving test_io to be a module. In that case still will need a module where the common "mocks" live (My tentative plan is test.test_io._support). I think this sets up for more understandable structure to the io tests overall, but happy to explore the problem space if desired.

  • Issue: Move Buffered tests from test_io to test_bufio #138013

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cmaloney
pythongh-138013: Move test.test_io to be a module
4e0fb32
This sets up for having a test_io._support which contains the I/O mocks
for sharing between multiple `io` module test files. Also starts a path
for all the `io` module tests to live in a single module for simpler
running rather than requiring knowledge of the list of `io` tests which
lives in `test_io`.

Keeps `python -m test test_io -uall -M8g` and `python -m test.test_io` running the
same set of tests as before.
@cmaloney
cmaloney requested review from AA-Turner and erlend-aasland as code owners August 26, 2025 00:49
@bedevere-app bedevere-app Bot added the awaiting review label Aug 26, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Aug 26, 2025
Move Buffered tests from test_io to test_bufio #138013
Closed
@AA-Turner

AA-Turner commented Aug 26, 2025

Copy link
Copy Markdown
Member

This sets up for having a test_io._support which contains the I/O mocks for sharing between multiple io module test files.

The usual pattern is test.test_support.{topic}_helper, isn't it? Can you elaborate on the proposed _support module?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cmaloney

cmaloney commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

I was following what I saw in a couple instances (ex. test_string: https://github.com/python/cpython/blob/main/Lib/test/test_string/_support.py, test_zoneinfo: https://github.com/python/cpython/blob/main/Lib/test/test_zoneinfo/_support.py). There's also a couple of support.py (ex. https://github.com/python/cpython/blob/main/Lib/test/test_tkinter/support.py). No idea what is most common or being worked towards as layout.

The IO Mocks are only useful for testing the two io module implementations (_io C and _pyio Python) and have specific to io naming patterns that are currently required (ex. MockRawIO -> CMockRawIO, PyMockRawIO + load_tests injection https://github.com/python/cpython/blob/main/Lib/test/test_io.py#L5040-L5077). Things in test.support feel like they're useful for testing multiple Python modules which I don't think these mocks are.

AA-Turner and yihong0618 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cmaloney

cmaloney commented Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

Another approach here would be to make a mock_io.py which mirrors https://github.com/python/cpython/blob/main/Lib/test/mock_socket.py, which would leave test_io.py in the current location (and not need a __main__.py + __init__.py).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AA-Turner
AA-Turner reviewed Aug 26, 2025
View reviewed changes
Comment thread Lib/test/test_io/test_general.py
Comment on lines 5 to 10
# * test_memoryio - tests BytesIO and StringIO
# * test_fileio - tests FileIO
# * test_file - tests the file interface
# * test_io - tests everything else in the io module
# * test_io.test_general - tests everything else in the io module
# * test_univnewlines - tests universal newline support
# * test_largefile - tests operations on a file greater than 2**32 bytes

@AA-Turner AA-Turner Aug 26, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Should the modules here be moved into the new package?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cmaloney cmaloney Aug 26, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

My plan is yes over time, just limiting scope of changes (and PRs) to pieces I'm actively working on changing (Currently Buffered I/O layer). test_bufio I plan to do as part of this overall issue (gh-138013). Not sure how much people rely on the names currently (ex. tracking performance over time by measuring test runtime). Unfortunately there are no benchmarks for CPython I/O in pyperformance currently (is part of my backlog to add).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@AA-Turner AA-Turner Aug 27, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The tests can and do move around, we don't make any guarantees here. Performance tests should use the pyperformance suite.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cmaloney reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@AA-Turner

AA-Turner commented Aug 26, 2025

Copy link
Copy Markdown
Member

If only useful within test_io then a test_io._mock_io or similar seems appropriate, thanks for the explanation.

cmaloney and yihong0618 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cmaloney

cmaloney commented Aug 27, 2025

Copy link
Copy Markdown
Contributor Author

Could this get a skip news tag? (Test-only change)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner AA-Turner added the skip news label Aug 27, 2025
AA-Turner
AA-Turner approved these changes Aug 27, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 27, 2025
@AA-Turner
AA-Turner merged commit 15e37ea into python:main Aug 31, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 31, 2025
@cmaloney
cmaloney deleted the test_io_load_tests_rework branch August 31, 2025 19:27
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
@cmaloney @lkollar
pythongh-138013: Make test.test_io into a package (python#138153)
c787588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AA-Turner AA-Turner AA-Turner approved these changes
@erlend-aasland erlend-aasland Awaiting requested review from erlend-aasland erlend-aasland is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@cmaloney @AA-Turner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.