Created
January 5, 2017 21:24
-
-
Save svetlyak40wt/fbe480384e9e3f75b10523aa0b4fb6ce to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
from hamcrest import ( | |
assert_that, | |
has_entries, | |
is_not, | |
) | |
obj = {'foo': 'bar', 'other': 'key'} | |
print 'Object:', obj, '\n' | |
try: | |
print 'Checking if obj has_entries(blah=\'minor\')' | |
assert_that( | |
obj, | |
has_entries( | |
blah='minor', | |
) | |
) | |
except AssertionError as e: | |
print e | |
try: | |
print 'Checking if obj is_not(has_entries(foo=\'bar\'))' | |
assert_that( | |
obj, | |
is_not( | |
has_entries( | |
foo='bar', | |
) | |
) | |
) | |
except AssertionError as e: | |
print e |
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
Object: {'foo': 'bar', 'other': 'key'} | |
Checking if obj has_entries(blah='minor') | |
Expected: a dictionary containing {'blah': 'minor'} | |
but: no 'blah' key in <{'foo': 'bar', 'other': 'key'}> | |
Checking if obj is_not(has_entries(foo='bar')) | |
Expected: not a dictionary containing {'foo': 'bar'} | |
but: was <{'foo': 'bar', 'other': 'key'}> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment