Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-13236: Flush the output stream more often in unittest #29864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2021

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Nov 30, 2021

It can prevent some losses when output to buffered stream.

https://bugs.python.org/issue13236

It can prevent some losses when output to buffered stream.
@arhadthedev
Copy link
Member

Would it be better to replace all self.stream.flush() with -u command line flag in TESTPYTHON/TESTRUNNER?

$ python -h
[...]
-u     : force the stdout and stderr streams to be unbuffered;
         this option has no effect on stdin; also PYTHONUNBUFFERED=x
[...]

Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchaka
Copy link
Member Author

'-u' only affects sys.stdout and sys.stderr. unittest.TextTestRunner can be used with other streams.

Also -u can affect behavior of the tested code.

And it is not only about running Python tests. unittest is used in third-party code.

@serhiy-storchaka serhiy-storchaka merged commit f42a06b into python:main Dec 4, 2021
@serhiy-storchaka serhiy-storchaka deleted the unittest-flush branch December 4, 2021 18:57
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker f42a06ba279c916fb67289e47f9bc60dc5dee4ee 3.10

@miss-islington
Copy link
Contributor

Sorry @serhiy-storchaka, I had trouble checking out the 3.9 backport branch.
Please backport using cherry_picker on command line.
cherry_picker f42a06ba279c916fb67289e47f9bc60dc5dee4ee 3.9

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Dec 5, 2021
…honGH-29864)

It can prevent some losses when output to buffered stream..
(cherry picked from commit f42a06b)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-bot
Copy link

GH-29929 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Dec 5, 2021
@serhiy-storchaka serhiy-storchaka removed their assignment Dec 5, 2021
ambv pushed a commit that referenced this pull request Dec 10, 2021
…29864) (GH-29929)

It can prevent some losses when output to buffered stream..
(cherry picked from commit f42a06b)

Co-authored-by: Serhiy Storchaka <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 10, 2021
…honGH-29864) (pythonGH-29929)

It can prevent some losses when output to buffered stream..
(cherry picked from commit f42a06b)

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit 83fa129)

Co-authored-by: Serhiy Storchaka <[email protected]>
@ZeroIntensity ZeroIntensity removed the needs backport to 3.9 only security fixes label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants