Refactor direct fixture call warning to avoid incompatibility with plugins#3754
Conversation
changelog/3747.bugfix.rst
Outdated
| @@ -0,0 +1 @@ | |||
| Fix compatibility problem with plugins and the the warning code issued by fixture functions when they are called directly. | |||
|
Hmmm 2 failing tests on py27, I will take a look at them tomorrow if the current approach is considered sound by others. |
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
the approach is sound, lets take a look at __wrapped__ to see if that fixes the issue
| return obj | ||
|
|
||
|
|
||
| def get_real_method(obj, holder): |
There was a problem hiding this comment.
this needs to handle __wrapped__ on python2
There was a problem hiding this comment.
Hmm get_real_func already handles __wrapped__. Can you clarify this a bit?
There was a problem hiding this comment.
@nicoddemus my understanding is that method descriptors are not exposing it readily, i will investigate in a bit
…ugins This refactors the code so we have the real function object right during collection. This avoids having to unwrap it later and lose attached information such as "async" functions. Fix pytest-dev#3747
1228b41 to
c6b11b9
Compare
| # during fixture definition we wrap the original fixture function | ||
| # to issue a warning if called directly, so here we unwrap it in order to not emit the warning | ||
| # when pytest itself calls the fixture function | ||
| if six.PY2 and unittest: |
There was a problem hiding this comment.
This was the best I could come with; unbound methods are a headache to deal here.
There was a problem hiding this comment.
cant wait for the python2 drop ^^
This refactors the code so we have the real function object right during
collection. This avoids having to unwrap it later and lose attached information
such as "async" functions.
I've tested this with
pytest-asyncioand it fixes pytest-dev/pytest-asyncio#89.Fix #3747, Fix #3720
Fix pytest-dev/pytest-asyncio#89