-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Do not buffer output #1886
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
Comments
I disagree - output buffering is there for a reason, and basically every application buffers its output by default. I don't think there's a good reason to do anything different than that. |
IIRC the buffering does not happen when running on a terminal anyway (the common use case). |
Isn't the "normal" unix behaviour to detect if it's being run in a pipeline and then disable the buffering? In fact I'm surprised python does not behave like that by default. Unless there's something we do in pytest which actually disables this? If so I'd say this is still a bug, we should behave fine either on terminal or in a pipe. |
this is a python bug |
So we could disable the output buffering explicitly then? FWIW, to make control characters (e.g. cursor keys, but also C-a) work with
|
this is handled at the python level, - we can enforce flushes what use case are you trying to implement? |
My use case is using https://github.com/janko-m/vim-test with https://github.com/radenling/vim-dispatch-neovim: vim-dispatch-neovim uses a Neovim terminal instance and that causes lines to be wrapped at its width (which might be really narrow in a tmux split etc). |
just do a |
i mean for that use case py.test should have a non-gui stdout output format that allows to present things nicely ideally flushed json-lines or anything that can be piped to a presentation layer directly without enforcing the normal output text limitations |
@RonnyPfannschmidt
Agreed. |
whops, my error, i meant |
@blueyed can this be closed as upstream python bug? |
@RonnyPfannschmidt |
@blueyed still an issue for pip/a pep |
@RonnyPfannschmidt |
@blueyed no, setuptools/pip doesn't support that in entry-point scripts and i'm inclined to NOT invent it because it will be an maintenance pain wit regular platform issues |
Please also note that python supports setting this through an
If the heart of this issue is to use pytest in a vim plugin, I think making the plugin set the environment variable before calling the entry point is perfectly acceptable. Like @RonnyPfannschmidt I also do not want to change the default behavior as we can't know the repercussions of such a fundamental change, and introducing an option to set this seems like overkill when python already provides two ways for users to change that setting. |
Closing it then. |
I am using py.test version 2.4.2 and Python version 2.6.6 and want to view ANSI colours within
What does work for me is
|
|
To add that
|
Uh oh!
There was an error while loading. Please reload this page.
When piping pytests output e.g. into
tee
it will get buffered.To work around this, you can e.g. export
PYTHONUNBUFFERED=1
or add-u
to the shebang line of thepytest
script (see http://stackoverflow.com/questions/107705/disable-output-buffering).I think it makes sense to enable it by default.
The text was updated successfully, but these errors were encountered: