-
-
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
Xfail marker for non-standard Item missing obj
#2231
Comments
I think the quick workaround is adding a dummy object like you propose. But I also think Would you mind to submit a PR which removes that requirement from there? I think this should do it: def _getglobals(self):
d = {'os': os, 'sys': sys, 'config': self.item.config}
if hasattr(self.item, 'obj'):
d.update(self.item.obj.__globals__)
return d What do you think @RonnyPfannschmidt? |
See pytest-dev#2231 for discussion.
I see now that an alternative solution was proposed in #2142 . |
I think they complement each other, with your's fixing the underlying problem more correctly. 👍 |
Hi!
We're currently writing a plugin for py.test that collects custom tests (i.e. our own class that inherits from
pytest.Item
). I want to add an xfail marker to these, so I try to do this dynamically viaitem.add_marker()
. If I do this, and run the tests, it will fail on this line:Here, the
skipping
plugin assumes that the item has anobj
attribute, which again has a__globals__
attribute. I can side-step this issue by simply adding a dummy variable here, with an empty__globals__
dict, but I want to ensure that:obj
attributeAm I doing it right? 😄
The text was updated successfully, but these errors were encountered: