You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
assert_trace does not work correctly with functions that use the same decorator #876
Our assert_trace from pytest plugin doesn't work correctly when two or more different functions are using the same decorator, it not considers that those functions are different! See the example below:
Also doesn't work, I tested with safe too (safe uses wraps) wraps just keep some metadata like name and docstring. But if we get the code from them they are the same
I know how to solve this issue! Reading the Python docs I discovered that wrapped functions has the __wrapped__ attribute which we can use to get the "original" function!
The users just need to pay attention to use the wraps decorator inside their decorators!
The thing is, fixing this (with the actual code ive made) we won't be able to handle creations within decorators cause we're getting the most inner function, @safe won't work for example:
Activity
sobolevn commentedon Mar 27, 2021
What if we use
@wrapsondef decorated? 🤔thepabloaguilar commentedon Mar 27, 2021
Also doesn't work, I tested with
safetoo (safe uses wraps)wrapsjust keep some metadata like name and docstring. But if we get the code from them they are the samethepabloaguilar commentedon Nov 3, 2022
I know how to solve this issue! Reading the Python docs I discovered that wrapped functions has the
__wrapped__attribute which we can use to get the "original" function!The users just need to pay attention to use the
wrapsdecorator inside their decorators!Docs: https://docs.python.org/3/library/functools.html#functools.update_wrapper
sobolevn commentedon Nov 3, 2022
Let's add this to the docs :)
thepabloaguilar commentedon Nov 10, 2022
I made the fix and broke other part 😆
The thing is, fixing this (with the actual code ive made) we won't be able to handle creations within decorators cause we're getting the most inner function,
@safewon't work for example:Failureis being created insidesafeand not_safe_decorated_functionSuggestions?
sobolevn commentedon Nov 10, 2022
No :(
Fix assert_trace matching other functions with the same decorator (#2552