Hi, Perhaps this could a plugin (pytest-datadiff)? I know you can customize assertion messages for other types (see http://pytest.org/latest/assert.html#defining-your-own-assertion-comparison), but I don't know how that plays with assertions already built in pytest.
Cheers, On Tue, Jul 29, 2014 at 5:24 AM, Anatoly Bubenkov <bubenk...@gmail.com> wrote: > what do you think about extending the existing assert representation with > this > https://pypi.python.org/pypi/datadiff > would be nice if we could extend datadiff with what pytest does for string > diff > and then just use datadiff for all assertions > because for now, it's not too useful to see a comparison of 2 dicts in the > pytest > it's not readable > especially if 2 dicts are big > and nowadays, json so dicts are everywhere > datadiff is cool at showing the diff between 2 dicts > the reason why im asking without the PR is the politics about the > dependencies > as i know you're not so positive about adding them > also this standalone mode is a bit tricky in that case, i guess > example: > > def test_ticket_filter_on_order_uid__in(app, first_ticket, second_ticket, > second_basket_ticket, order, second_order): > """Test if the right result is returned when filtering on basket.""" > ticket_filter = pta.ticket.filter(api_key=app.uid, > order_uid__in=[order['uid']]).content > > assert ticket_filter == [first_ticket, second_ticket] > E assert [{'code': '91...dulum'}, ...}] == [{'basket_uid'... 'EUR'}, ...}] > E At index 0 diff: {'code': '911338060856', 'subtitle': {'en': u'Subtitle1 > Kaleidoscope'}, 'uid': u'37bc3c15e66a45e9bf3b52233fcdff02', 'order_uid': > u'08dec1bd7ec249109729de448ffcc571', 'price': {'currency': 'EUR', 'amount': > '1.20'}, 'fees': [{'price': {'currency': 'EUR', 'amount': '2.00'}, 'type': > 'service costs'}], 'product_uid': u'32c2a6f98f0642b9843a8dcce6dead56', > 'name': {'en': u'Ticket1 \u2603 Weapon'}} != {'subtitle': {'en': > u'Subtitle1 Kaleidoscope'}, 'uid': u'37bc3c15e66a45e9bf3b52233fcdff02', > 'price': {'currency': 'EUR', 'amount': '1.20'}, 'fees': [{'price': > {'currency': 'EUR', 'amount': '2.00'}, 'type': 'service costs'}], > 'basket_uid': u'871e829da04e4cd9a45d244f55824c83', 'product_uid': > u'32c2a6f98f0642b9843a8dcce6dead56', 'name': {'en': u'Ticket1 \u2603 > Weapon'}} > just unreadable > > > -- > Anatoly Bubenkov > > _______________________________________________ > Pytest-dev mailing list > Pytest-dev@python.org > https://mail.python.org/mailman/listinfo/pytest-dev > >
_______________________________________________ Pytest-dev mailing list Pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev