-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
logging not captured with pytest 3.3 and xdist #3009
Comments
I managed to track this problem to the fact that pytest's Lines 327 to 337 in 88f2cc9
This handler is attached directly to Lines 263 to 272 in 88f2cc9
This is problematic, because we are now capturing the log output twice, once by the pytest's logging capture and another time by pytest's logging capture:
One guess is that the order in which plugins are registered matter here, but changing the order of builtin plugins in config does not change the output: Lines 104 to 108 in 88f2cc9
The same doesn't happen in
Looking at pytest_catchlog/plugin.py I see that it has the same functionality, so I'm not sure yet what's the bug. I will continue to investigate when I have some more time. cc @thisch |
I'm investigating this issue. |
I don't know why but I can no longer reproduce the issue.
|
@thisch when you say "no longer", you mean you at some point could reproduce it and it stopped without apparent cause, or you never seeing this problem in the first place? |
Investigating a more, I noticed that the released If I install
OK, that mystery is solved then! 😅 The "live logs" feature seems to have been added in eisensheng/pytest-catchlog#33 and never been released, which explains why nobody noticed this before. |
I saw it once but when working on a fix this issue vanished, even when switching back to the HEAD of origin/master. I can't explain this ... Yes unfortunately the live test logging feature hasn't been released yet in pytest-catchlog. (That was one of the reason why I wanted to merge it into pytest-core) I'm glad that this mystery is solved. :) Do you think that we should try to remove the loglines from the captured stderr output in your example? IMO they should only be visible in the "captured log call" section. |
Yep!
I think by default we should not show the the captured log also on stderr, given that we already capturing it. IOW, I think we "live log" should be opt-in, instead the default. As it stands, the only way to disable it is to set [pytest]
log_cli_level=9999 Not sure if that should be the default behavior; my take is that pytest should produce clean output when things are passing, but I would like to hear other opinions on this. Either way, the current behavior is inconsistent: it is only printing the "live log" when running under So we have a bug and a request for change here IMO. If everyone agrees I will open separate a issue for the change request about live logs. |
Now that the problem has been identified, I'm closing this in favor of a concrete proposal: #3013 |
For new users of pytest (maybe coming here googling why their logs are not displayed when testing): based on https://docs.pytest.org/en/latest/logging.html I made this pytest.ini file, with which pytest will output all log messages (in a nicely formatted way).
BTW if anyone knows how to add millisecs to log_date_format, it would be welcome. %f does not seem to work (using pytest 3.6.3). |
On Mon, Jul 9, 2018 at 1:14 PM Attila ***@***.***> wrote:
BTW if anyone knows how to add millisecs to log_date_format, it would be
welcome. %f does not seem to work (using pytest 3.6.3).
Hope this helps.
You can use "'%(asctime)s.%(msecs)03d" in your log_format.
HTH
'
… —
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3009 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMm9UUsIciyFPf49FFqpXoUvGxyghSRks5uEzr8gaJpZM4Q5ZTI>
.
|
(Moved from pytest-dev/pytest-xdist#256)
Consider this file:
When executing
pytest foo.py -n2
, the warning is printed to the console:Executing
pytest
normally without the-n2
flags then the message is not printed.Using
pytest 3.3.1
andxdist 1.20.1
.The text was updated successfully, but these errors were encountered: