-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Make record_xml_property generic and compatible with xdist and markers. #2770
Conversation
85e9644
to
6ca04bd
Compare
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.
hi Carlos,
thanks for this addition, this is a nicely done next step,
however we do have some major problems there
a) this breaks backward compatibility harshly - a removal without a deprecation period is unacceptable
a backward compatibility fixture that's just an alias triggering a deprecating warning for the node should be fine
b) this removes the warning about being experimental - which would remove a safety net that's there for our own sake
@RonnyPfannschmidt totally reasonable. I'll add those. Thanks for the review. |
@RonnyPfannschmidt deprecation warnings added. Back to you. |
As @RonnyPfannschmidt said, thanks a lot again @carlos-jenkins for your work! At first seems like a good step forward. Some thoughts we should discuss:
|
@carlos-jenkins gentle ping, would like to hear if you have any thoughts about my comments. |
Hi @nicoddemus , sorry I didn't commented earlier, I had my priorities shifted and was unable to keep working on this branch. In relation to your comments:
|
No worries, thanks for getting back to this.
Good point, I agree.
Fair enough, let's go with that! 👍 |
hey, I just solved some merge conflicts :) is this PR ready to go? (I see the @RonnyPfannschmidt requested changes were applied) |
Thanks @dajose, would you mind take a look at the CI errors? |
Also because this is a new feature, this PR should target the |
it seems doc-tests lack the feature right now |
_pytest/python.py
Outdated
@@ -1132,6 +1132,10 @@ def __init__(self, name, parent, args=None, config=None, | |||
#: .. versionadded:: 3.0 | |||
self.originalname = originalname | |||
|
|||
#: user properties is a list of tuples (name, value) that holds user | |||
#: defined properties for this test. | |||
self.user_properties = [] |
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.
we either need to add this in more places, or default to a empty list when trying to fetch it (i beleive its a good idea to move it to the item class)
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.
Thanks for the idea :)
I just added a commit with that change
original problem was nicely handled
could you help me understanding the CI checks? it seems to me like there was some error unrelated with the changes Also, @nicoddemus is this PR really a "feature"? I think it like a enhancement to support an existing functionality when using xdist. |
Hi @dajose and @carlos-jenkins, sorry for the delay.
You are correct, we just use the "features" branch as the target for enhancements/features for the next minor release. This should not go into a new bugfix release ( |
About the checks: they seem unrelated and can be ignored. |
@nicoddemus so, we close this PR and open another for branch features? (is there other way to do that?) |
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.
Aside from my minor comment this looks good to go from my POV. 👍
_pytest/runner.py
Outdated
@@ -315,7 +316,8 @@ class TestReport(BaseReport): | |||
""" | |||
|
|||
def __init__(self, nodeid, location, keywords, outcome, | |||
longrepr, when, sections=(), duration=0, **extra): | |||
longrepr, when, user_properties, |
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.
I think user_properties
should go after duration
to avoid breaking clients needlessly.
@dajose you can change the target of the branch by clicking on the After that it will probably be better to rebase your commits into the |
@carlos-jenkins can you rebase so it turns merge-able again? |
Hi @carlos-jenkins, This is a highly useful functionality. When can we merge this PR. |
453cca6
to
3377c2f
Compare
dd7120c
to
4a7e234
Compare
…d logic so that the properties are passed to the TestReport object and thus allow compatibility with pytest-xdist.
4a7e234
to
8b49ddf
Compare
@RonnyPfannschmidt @nicoddemus rebase done. Now waiting for CI. |
Also make record_xml_property return record_property directly
@RonnyPfannschmidt @nicoddemus CI ready :D |
Thanks a ton @carlos-jenkins! I just pushed two small changes: added a note about deprecating This is ready for merging from my POV! 👍 |
Starting 2018 (many pytest versions ago) the correct way to record properties is by using the "record_property" method pytest-dev/pytest#2770
This PR changes the
record_xml_property
function with a more genericrecord_property
that is compatible with xdist, markers, and any other reporter other than the JUnit reporter.The implementation adds a list of
user_properties
to the item object, and can be modified anytime after its creation during the test lifecycle. When the test has finished, the user properties are passed to the TestReport object, which is shared with any reporter, and in particular serialized and sent to the master in xdist, and then the reporter are free to plot this properties as they want.Currently, to maintain the functionality, the JUnit adds those properties to the XML report.
In addition, this allows markers to modify (add, delete) user properties as desired. This is documented in this PR and a particular use case is:
That allows to use markers as follows:
Regards