gh-128377: Fix `test_cmd_line.test_non_interactive_output_buffering` fail with `PYTHONUNBUFFERED=1` by WolframAlph · Pull Request #128378 · python/cpython · GitHub
Skip to content

gh-128377: Fix test_cmd_line.test_non_interactive_output_buffering fail with PYTHONUNBUFFERED=1 - #128378

Merged
picnixz merged 8 commits into
python:mainfrom
WolframAlph:fix-testcmdline
Jan 12, 2025
Merged

picnixz merged 8 commits into
python:mainfrom
WolframAlph:fix-testcmdline

Conversation

@WolframAlph

@WolframAlph WolframAlph commented Dec 31, 2024

Copy link
Copy Markdown
Contributor

@WolframAlph WolframAlph changed the title gh-128377: Fix test_cmd_line fail with PYTHONUNBUFFERED=1 gh-128377: Fix test_cmd_line.test_non_interactive_output_buffering fail with PYTHONUNBUFFERED=1 Dec 31, 2024
Comment thread Lib/test/test_cmd_line.py Outdated
Comment thread Lib/test/test_cmd_line.py Outdated

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should use os_helper.EnvironmentVarGuard() instead of manually messing with os.environ.

@picnixz

picnixz commented Dec 31, 2024

Copy link
Copy Markdown
Member

@WolframAlph

Copy link
Copy Markdown
Contributor Author

@ZeroIntensity thanks for pointing to that

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM (for reviewers, it's easier to hide whitespace changes).

@ZeroIntensity ZeroIntensity left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This works, but feels kind of hacky. Why not just unittest.skipIf(os.environ.get("PYTHONUNBUFFERED"))? (Also I'd like to hear @picnixz's preference.)

@picnixz

picnixz commented Jan 1, 2025

Copy link
Copy Markdown
Member

Now that you're raising this issue, I'd actually prefer skipping it. If the test is broken when you use PYTHONUNBUFFERED=1 (broken because of unsatisfied pre-requirements, namely it could never work with this configuration), then it's probably fine to just skip it. Changing locally the environment is like saying "hey, you run the test suite with this configuration, but this test is not compatible with that configuration, so we'll temporarily change your configuration so that the test can run".

So yes, let's just skip the test.

Comment thread Lib/test/test_cmd_line.py Outdated
@WolframAlph

Copy link
Copy Markdown
Contributor Author

Sorry linter failed, did not have pre-commit hooks installed. Will fix asap

@WolframAlph
WolframAlph requested a review from picnixz January 11, 2025 08:15
Comment thread Lib/test/test_cmd_line.py Outdated
@picnixz

picnixz commented Jan 11, 2025

Copy link
Copy Markdown
Member

Thanks. I'll merge this one tomorrow (I'll write a nice commit message).

@ZeroIntensity

Copy link
Copy Markdown
Member

Having fun with your commit privileges already I see 😄

@picnixz
picnixz merged commit 30268b5 into python:main Jan 12, 2025
@picnixz

picnixz commented Jan 12, 2025

Copy link
Copy Markdown
Member

Thank you for the fix and the reviews!

@picnixz

picnixz commented Jan 12, 2025

Copy link
Copy Markdown
Member

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.

3 participants