-
-
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
Allow user to select if he wants log, std-out/err in junit capture xml file, and respect his decision #6415
Conversation
@nicoddemus can you have a look now, please? |
Not sure what's going on on your side, but I've fixed linting by running I plan to take a look later this, meanwhile could you write a description for the PR? It makes easier for people to get context when reviewing. 👍 |
@nicoddemus sure, I added a description as to what purpose this PR serves. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR @dxtr85, thanks!
Besides my other comments:
-
This should target
features
, as it is a new feature. -
Please add yourself to the
AUTHORS
file. -
Add a CHANGELOG entry, I suggest a file
changelog/6415.feature.rst
with contents like this:The :confval:`junit_logging` config option now supports a new set of values: `no`, `log`, `system-out`, `system-err`, `out-err`, and `all`.
@@ -523,7 +538,9 @@ def test_func(arg1): | |||
assert 0 | |||
""" | |||
) | |||
result, dom = run_and_parse(family=xunit_family) | |||
result, dom = run_and_parse( | |||
"-o", "junit_logging=system-out", family=xunit_family |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this needed to change, could you explain it please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since the default value is still no
but the behavior reflects what >no< means, that is there is nothing stored neither from log, system-out nor system-err by default.
That is why I had to set junit_logging
explicitly to system-out
so that later sysout
variable is not None
assert "warning msg" not in systemerr_xml | ||
assert "ValueError" in fnode.toxml(), "ValueError not included" | ||
|
||
if junit_logging in ["log", "all"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, this logic is much simpler to follow. 👍
@@ -408,9 +385,9 @@ def pytest_addoption(parser): | |||
parser.addini( | |||
"junit_logging", | |||
"Write captured log messages to JUnit report: " | |||
"one of no|system-out|system-err", | |||
"one of no|log|system-out|system-err|out-err|all", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the reference docs:
https://github.com/pytest-dev/pytest/blob/master/doc/en/reference.rst#L1164-L1174
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh also given that this is a new feature, please rebase it on features
. 👍
I will close this PR since another one has been opened containing changes requested in this one. |
The purpose for this PR is enabling user to set what should be contained in generated xml file since for some (me included) this file is used only for report generation, hence log/out/err are not always welcome, and can take lots of space.
User can pick between no|log|system-out|system-err|out-err|all in order to put selected output in xml file.