-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
topic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
from typing import NamedTuple
class Cart(NamedTuple):
num_items: int
total_cost: float
def test_cart():
assert Cart(1, 10) == Cart(1, 20)
pytest failure message:
def test_cart():
> assert Cart(1, 10) == Cart(1, 20)
E assert Cart(num_item...total_cost=10) == Cart(num_item...total_cost=20)
E At index 1 diff: 10 != 20
E Use -v to get the full diff
It would nice if the field name was shown in the assertion failure message, rather than an index, eg:
def test_cart():
> assert Cart(1, 10) == Cart(1, 20)
E assert Cart(num_item...total_cost=10) == Cart(num_item...total_cost=20)
E At index 1 (total_cost) diff: 10 != 20
E Use -v to get the full diff
Python 3.6.10
Pytest 5.4.3
Metadata
Metadata
Assignees
Labels
topic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch