• Custom Search

Comparing dictionaries in doctest

Here's a nifty way to compare dictionaries in doctest in Python.

 

>>> d = function_that_returns_a_dict()

>>> expected_d = {... some expected result }

>>> d = True if d == expected_d else d
>>> d
True

Technorati tags: ,

Read more work,wow articles

This entry was posted in work, wow. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*