예제 #1
0
    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")
예제 #2
0
 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))
예제 #3
0
 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")
예제 #4
0
 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))
예제 #5
0
 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. ")
예제 #6
0
 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. ")
예제 #7
0
 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")
예제 #8
0
 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'. ")
예제 #9
0
 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. ")
예제 #10
0
 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")
예제 #11
0
 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. ")
예제 #12
0
 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")