-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
assert_trace
does not work correctly with functions that use the same decorator
#876
Comments
What if we use |
Also doesn't work, I tested with |
I know how to solve this issue! Reading the Python docs I discovered that wrapped functions has the The users just need to pay attention to use the Docs: https://docs.python.org/3/library/functools.html#functools.update_wrapper |
Let's add this to the docs :) |
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, @safe
def _safe_decorated_function(return_failure: bool = False):
if return_failure:
raise ValueError('Function failed')
def test_something():
with returns.assert_trace(container_type, _safe_decorated_function):
_safe_decorated_function(True)
Suggestions? |
No :( |
Bug report
What's wrong
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:That test should fail because we want to assert the
Success
creation insidefunc_one
, but I'm callingfunc_two
and the test is passing!How is that should be
Our pytest plugin should consider that those functions are different!
System information
python
version: 3.9returns
version: 0.16.0The text was updated successfully, but these errors were encountered: