-
-
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 passing plugins as str objects a more obvious failure #860
Make passing plugins as str objects a more obvious failure #860
Conversation
4ee71c8
to
0f36cbc
Compare
@@ -80,6 +80,9 @@ def _prepareconfig(args=None, plugins=None): | |||
try: | |||
if plugins: | |||
for plugin in plugins: | |||
if isinstance(plugin, str): |
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.
Maybe warn in case of unicode strings as well? Not sure how pytest handles the 2/3 split though.
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.
Using py.builtin._basestring
IIRC
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.
Done, thanks! 😄
I think it would be better to do this fix in pluggy rather then in py.test to be honest. Also, is something like |
Hum, maybe the isinstance I suggest is not really in the spirit of ducktyping. And hence the generic approach in pluggy not so great. Furthermore a plugin could provide no hooks but only some fixtures in which case the generic approach in pluggy is also not so great. So maybe my previous comment is wrong and this PR is the right approach anyway. |
Well you'd also need to add
It just happens that my original use case was indeed a plugin which only provided fixtures, no hooks. And my feature request was about excluding strings: I had thought that since -p takes a "string" designator for plugins it could also work for the plugins argument. It is an ID10T error, but one which I think has at least a bit of logic threaded through it. |
random thought, could we just consider strings in the same manner we consider the -p option ? |
That would certainly be an alternative. |
Good idea @RonnyPfannschmidt, updated the PR to interpret strings as module names instead. 😄 |
b669445
to
449cfcd
Compare
449cfcd
to
35bbcc3
Compare
+1 |
Make passing plugins as str objects a more obvious failure
See #855
CC @xmo-odoo