def test_matches_by_match_failure_with_message(self): matcher = re.compile('ab.*') try: Assert.matches("Absolutely", matcher, msg="failure message") except AssertionError as e: Assert.equal(e.msg, "'Absolutely' did not match 'ab.*'. failure message")
def test_dict_does_not_contain_key_failure_with_message(self): dict3 = { 'd': 'dvalue', 'e': 'evalue', 'f': 'fvalue', } try: Assert.does_not_contain('d', dict3, msg="failure message") except AssertionError as e: Assert.equal(e.msg, "%s should not be found in %s. failure message" % ('d', dict3))
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")
def test_list_of_dicts_does_not_contain_dict_failure_no_message(self): dict1 = { 'a': 'avalue', 'b': 'bvalue', 'c': 'cvalue', } dict2 = { 'a': 'dvalue', 'b': 'evalue', 'c': 'fvalue', } dict3 = { 'd': 'dvalue', 'e': 'evalue', 'f': 'fvalue', } list_of_dicts = [ dict1, dict2, dict3 ] try: Assert.does_not_contain(dict3, list_of_dicts) except AssertionError as e: Assert.equal(e.msg, "%s should not be found in %s. " % (dict3, list_of_dicts))
def test_contains_failure_without_message(self): try: Assert.contains("a", "bcd") except AssertionError as e: Assert.equal(e.msg, "a is not found in bcd. ")
def test_between_failure_without_message(self): try: Assert.between('along', 'alone', 'allow') except AssertionError as e: Assert.equal(e.msg, "along is not between alone and allow. ")
def test_between_failure_with_message(self): try: Assert.between(11, 5, 10, msg='failure message') except AssertionError as e: Assert.equal(e.msg, "11 is not between 5 and 10. failure message")
def test_matches_by_string_failure_no_message(self): try: Assert.matches('Absolutely', '^sol') except AssertionError as e: Assert.equal(e.msg, "'Absolutely' did not match '^sol'. ")
def test_rounded_failure_no_message(self): try: Assert.rounded(14.983, 14.985) except AssertionError as e: Assert.equal(e.msg, "neither 14.983 nor 14.985 is a round of the other. ")
def test_rounded_failure_with_message(self): try: Assert.rounded(13, 19, msg="failure message") except AssertionError as e: Assert.equal(e.msg, "neither 13 nor 19 is a round of the other. failure message")
def test_nearly_failure_without_message(self): try: Assert.nearly(34, 42, 3) except AssertionError as e: Assert.equal(e.msg, "34 is not within 3 of 42. ")
def test_nearly_failure_with_message(self): try: Assert.nearly(3.15, 3.14159265, "pi rounded improperly") except AssertionError as e: Assert.equal(e.msg, "3.15 is not within 0.005 of 3.14159256. pi rounded improperly")