Created
October 24, 2014 09:45
-
-
Save medwards/2fc2ae1c42f8ee7becbf to your computer and use it in GitHub Desktop.
Expected GOES FIRST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nose.tools import assert_equals # pip install nosetests | |
assert_equals("first", "second") | |
# Nothing fancy here, just default string comparison | |
# AssertionError: 'first' != 'second' | |
# Lets compare a dictionary | |
assert_equals({'a': 'foo'}, {'a': 'bar'}) | |
# This produces a cool little diff | |
# AssertionError: {'a': 'foo'} != {'a': 'bar'} | |
# - {'a': 'foo'} | |
# ? ^^^ | |
# | |
# + {'a': 'bar'} | |
# ? ^^^ | |
# When our test fails we want to know how the test result deviates from the expected result. | |
# Convention in diff output (as above) puts the 'baseline' value first | |
# So, kids, assert_equals(expected, result) for great justice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment