dry-python / dry-python/returns

`assert_trace` does not work correctly with functions that use the same decorator

未关闭
#876 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
Python
星标
4.4k
派生
155
平均合并
2 小时 27 分钟
30 天内合并 PR
22

描述

# 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:

```python
def test_two_functios_using_same_decorator(returns: ReturnsAsserts):
def decorator(func):
def decorated(*args, **kwargs):
return func(*args, **kwargs)
return decorated

@decorator
def func_one():
return Success(42)

@decorator
def func_two():
return Success(42)

with returns.assert_trace(Success, func_one):
func_two()
```

That test should fail because we want to assert the `Success` creation inside `func_one`, but I'm calling `func_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.9
- `returns` version: 0.16.0

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。