예제 #1
0
class TestAnnotate(TestCase, TestMatchersInterface):

    matches_matcher = Annotate("foo", Equals(1))
    matches_matches = [1]
    matches_mismatches = [2]

    str_examples = [("Annotate('foo', Equals(1))", Annotate("foo", Equals(1)))]

    describe_examples = [("2 != 1: foo", 2, Annotate('foo', Equals(1)))]

    def test_if_message_no_message(self):
        # Annotate.if_message returns the given matcher if there is no
        # message.
        matcher = Equals(1)
        not_annotated = Annotate.if_message('', matcher)
        self.assertIs(matcher, not_annotated)

    def test_if_message_given_message(self):
        # Annotate.if_message returns an annotated version of the matcher if a
        # message is provided.
        matcher = Equals(1)
        expected = Annotate('foo', matcher)
        annotated = Annotate.if_message('foo', matcher)
        self.assertThat(
            annotated,
            MatchesStructure.fromExample(expected, 'annotation', 'matcher'))
예제 #2
0
 def test_if_message_given_message(self):
     # Annotate.if_message returns an annotated version of the matcher if a
     # message is provided.
     matcher = Equals(1)
     expected = Annotate('foo', matcher)
     annotated = Annotate.if_message('foo', matcher)
     self.assertThat(
         annotated,
         MatchesStructure.fromExample(expected, 'annotation', 'matcher'))
예제 #3
0
 def test_if_message_given_message(self):
     # Annotate.if_message returns an annotated version of the matcher if a
     # message is provided.
     matcher = Equals(1)
     expected = Annotate("foo", matcher)
     annotated = Annotate.if_message("foo", matcher)
     self.assertThat(annotated, MatchesStructure.fromExample(expected, "annotation", "matcher"))
예제 #4
0
 def test_if_message_no_message(self):
     # Annotate.if_message returns the given matcher if there is no
     # message.
     matcher = Equals(1)
     not_annotated = Annotate.if_message('', matcher)
     self.assertIs(matcher, not_annotated)
예제 #5
0
 def test_if_message_no_message(self):
     # Annotate.if_message returns the given matcher if there is no
     # message.
     matcher = Equals(1)
     not_annotated = Annotate.if_message("", matcher)
     self.assertIs(matcher, not_annotated)