def test_deep_equals_ignore_extra_keys(self): # don't try to do it this way, it doesn't work # this is why we need Assert.complexly that does IGNORE_EXTRA_KEYS actual = { 'an_integer': 32, 'a_string': 'stupendous', 'a_float': 14.34, 'a_list': ['cat', 'dog', 'mouse'], } expected = { 'a_string': 'stupendous', } Assert.deep_equal(actual, expected, ignore_extra_keys=True)
def test_deep_equal_failure_missing_key_without_message(self): actual = { 'an_integer': 32, 'a_string': 'stupendous', 'a_list': ['cat', 'dog', 'mouse'], } expected = { 'an_integer': 32, 'a_string': 'stupendous', 'a_float': 14.342, 'a_list': ['cat', 'dog', 'mouse'], } try: Assert.deep_equal(actual, expected) except AssertionError as e: expected = "expected keys ['a_float'] are absent in actual" Assert.contains(expected, e.msg, )
def test_deep_equal_failure_extra_keys_with_message(self): actual = { 'an_integer': 32, 'a_string': 'stupendous', 'a_float': 14.34, 'a_list': ['cat', 'dog', 'mouse'], 'a_thing': 'thing' } expected = { 'an_integer': 32, 'a_string': 'stupendous', 'a_float': 14.342, 'a_list': ['cat', 'dog', 'mouse'], } try: Assert.deep_equal(actual, expected, msg="not complexly equal") except AssertionError as e: Assert.equal(e.msg, "not complexly equal")