Open allisonkarlitskaya opened 1 year ago
I'm under the impression that we ought to coordinate this with pytest and terminalweiter in some way
Personally I'd like to completely anhillate terminalweiter as is, It's a rather unfit api for UX in many ways
Unfortunately the design and migration work for that size of undertaking far exceeds the bounds of reasonably effort for your outlined usecase
A starting point might be a better tool to disable terminalweiter to begin with and a accompanying patch to xdist for using it on worker's and for respecting it's in normal operation
provide a simple mechanism to disable all output without playing around with unregistering plugins
A starting point might be a better tool to disable terminalweiter to begin with and a accompanying patch to xdist for using it on worker's and for respecting it's in normal operation
Perhaps we can add a new pytest option that completely disables pytest's own output? Then pytest-xdist could honor that option too.
For full safety we probably want something that ensures no output is made,which includes enforcement of output capture and terminalweiter silence
PS I believe this should be a api of config, and xdist,sugar,tap as well as bdd output plugins ought to use it in pytest-configure
For full safety we probably want something that ensures no output is made,which includes enforcement of output capture and terminalweiter silence
Not sure, I was thinking we could guarantee pytest itself will not output anything (effectively disabling the terminal writer), not go out of our way to ensure nothing gets written in the terminal... I believe this flag is enough for the OP?
PS I believe this should be a api of config, and xdist,sugar,tap as well as bdd output plugins ought to use it in pytest-configure
What API do you have in mind?
That's unclear as of now, naming and granularity needs Brainstorming
When creating the
DSession
object, pytest-xdist checks to see if theterminalreporter
plugin is registered with pytest, and if so, creates aTerminalDistReporter
object and registers it as a pytest plugin namedterminaldistreporter
.pytest-tap
tries to disable all terminal output (since it interferes with the tap output). This works by removing theterminalreporter
plugin. If you havexdist
andpytest_tap
both installed as site packages, this approach works fine — but only because thepytest_tap
configure hook happens to run first.If you try to do the same thing from your own
conftest.py
, though, you fall over fast. It's difficult to arrange for your configure hook to be called afterterminalreporter
has been created but before xdist checks for it. No worries — ourconftest.py
can run last and also remove theterminaldistreporter
plugin. Great!Unfortunately, this doesn't work. In addition to registering the plugin, the
DSession
takes a reference on it:and uses this
trdist
later, fromworker_collectionfinish
:and
It would be nice if there was a better way to silence pytest-xdist entirely. The "big hammer", of course, is to redirect
sys.stdout
entirely, but I'd prefer to avoid that if possible.So some alternatives:
TerminalDistReporter
until after the config step is done, making it more sensitive to changes in theterminalwriter
plugin.setstatus()
and.ensure_show_status()
APIs into hooks and call them that way. If the plugin gets unloaded then they won't be called — not harm done. That would also allow dropping the extraself.terminal
check (although there are some direct uses of those, as well, that would need to be fixed up).dsession
plugin and manually settingterminal
toNone
, but this doesn't really feel great...If any of these approaches are acceptable, I'm happy to write a patch.
Thanks!