hjwp / pytest-icdiff

better error messages for assert equals in pytest
The Unlicense
312 stars 18 forks source link

expression drill-down gone? #5

Open davidszotten opened 6 years ago

davidszotten commented 6 years ago

while the diffs are super helpful, it looks like it loses the very handy drill-down features:

def test_a():
    assert len([1, 2, 3]) == len([1, 2])

without plugin

test_foo.py:2: in test_a
    assert len([1, 2, 3]) == len([1, 2])
E   assert 3 == 2
E    +  where 3 = len([1, 2, 3])
E    +  and   2 = len([1, 2])

with plugin

test_foo.py:2: in test_a
    assert len([1, 2, 3]) == len([1, 2])
E   assert equals failed
E     3                                       2
hjwp commented 6 years ago

good point! any thoughts on how we could get them back?

hjwp commented 6 years ago

may be possible using hookwrapper -- https://docs.pytest.org/en/latest/writing_plugins.html#hookwrapper-executing-around-other-hooks

had a quick try but is full of pytest magic and me too tired rn.

hjwp commented 5 years ago

It occurs to me that maybe the times when you want drilldown and the times when you want icdiff aren't often the same cases -- like, in your example, we're comparing two small ints.

so one fix is maybe to special-case times when icdiff is unlikely to help, and then let pytest do its normal thing. I've added that for comparisons of numbers less than 100. Any other thoughts on when drilldown is likely to be more useful than icdiff?