dry-python / dry-python/returns

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

オープン
#876 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Python
スター
4.4k
フォーク
155
平均マージ
2時間 27分
マージ済み PR(30日)
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 を短くまとめたダイジェスト。