def test_can_specify_custom_message(self): assertion = lambda: assert_dict_contains(dict(foo='bar'), dict(foo='baz')) exception = assert_raises(AssertionError, assertion) assert_equals("'foo':'bar' not in {'foo': 'baz'}", exception_message(exception))
def test_has_sensible_default_error_message(self): assertion = lambda: assert_dict_contains(dict(definitely_missing='from other dict'), dict()) exception = assert_raises(AssertionError, assertion) assert_equals("'definitely_missing':'from other dict' not in {}", exception_message(exception))
def test_has_sensible_default_error_message_when_values_differ(self): assertion = lambda: assert_dict_contains(dict(foo='bar'), dict(foo='baz')) exception = assert_raises(AssertionError, assertion) assert_equals("'foo':'bar' not in {'foo': 'baz'}", exception_message(exception))
def test_can_detect_contained_dict(self): sub_dict = dict(foo='bar') super_dict = dict(foo='bar', bar='baz') assert_dict_contains(sub_dict, super_dict)
def test_throws_if_dict_is_not_contained(self): assertion = lambda: assert_dict_contains(dict(not_in='other dict'), dict()) assert_raises(AssertionError, assertion)
def test_has_sensible_default_error_message(self): assertion = lambda: assert_dict_contains( dict(definitely_missing='from other dict'), dict()) exception = assert_raises(AssertionError, assertion) assert_equals("'definitely_missing':'from other dict' not in {}", exception_message(exception))