Skip to content
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

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

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
Contributor

arhadthedev commented Nov 30, 2021

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

LGTM.

@serhiy-storchaka
Copy link
Member Author

serhiy-storchaka commented Nov 30, 2021

'-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
12 checks passed
@serhiy-storchaka serhiy-storchaka deleted the unittest-flush branch Dec 4, 2021
@miss-islington
Copy link
Contributor

miss-islington commented Dec 4, 2021

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

@miss-islington
Copy link
Contributor

miss-islington commented Dec 4, 2021

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

miss-islington commented Dec 4, 2021

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 <storchaka@gmail.com>
@bedevere-bot
Copy link

bedevere-bot commented Dec 5, 2021

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

@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 <storchaka@gmail.com>
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 <storchaka@gmail.com>
(cherry picked from commit 83fa129)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants