def test_not_matches__wrong_description_wrong_mismatch(
            self, never_matches, anything):
        """
        Dude

        Here we pass a matcher that never matches and check that the description is correct"""

        matcher = matches(anything)\
            .with_description("Wrong description")\
            .with_mismatch_description("Wrong mismatch description")
        match_result = matcher._matches(never_matches())

        assert_description(
            matcher,
            "A matcher that matches the item "
            "with the description: <Wrong description> and "
            "with tne mismatch_description: <Wrong mismatch description>.")

        assert_mismatch_description(
            matcher, never_matches(),
            "The matcher did not match, "
            "the description was <This is a description>, "
            "the mismatch_description was <This is a mismatch description>.")

        assert_that(match_result, is_(False))
 def test_matches(self, always_matches, anything):
     """assert_that(anything(), always_matches())
     We check that when we
     """
     matcher = matches(anything)
     match_result = matcher._matches(always_matches())
     assert_description(matcher, "A matcher that matches the item.")
     assert_that(match_result, is_(True))
 def test_matches_with_description(self, always_matches, anything):
     """assert_that(anything(), always_matches())
     We check that when we
     """
     matcher = matches(anything).with_description("This is a description")
     match_result = matcher._matches(always_matches())
     assert_description(
         matcher, "A matcher that matches the item "
         "with the description: <This is a description>.")
     assert_that(match_result, is_(True))
    def test_not_matches__no_description(self, never_matches, anything):
        """
        Dude

        Here we pass a matcher that never matches and check that the description is correct"""

        matcher = matches(anything)
        match_result = matcher._matches(never_matches())
        assert_mismatch_description(
            matcher, never_matches(), "The matcher did not match.")
        assert_that(match_result, is_(False))
    def test_simple_matches_but_mismatch_provided(self, always_matches, anything):
        """
        Check that when we call `matches` with a mismatch description we should get an error.
        """

        matcher = matches(anything).with_mismatch_description("wrong")
        match_result = matcher._matches(always_matches())

        assert_mismatch_description(
            matcher, always_matches(),
            "The matcher matched, but a mismatch description was provided.")

        assert_that(match_result, is_(False))
    def test_not_matches_with_wrong_description(self, always_matches, anything):
        """The .with_description() clause should be the description
        that the `always_matches()` matcher gives out."""

        matcher = matches(anything).with_description("Wrong description")
        match_result = matcher._matches(always_matches())

        assert_description(
            matcher, "A matcher that matches the item "
            "with the description: <Wrong description>.")

        assert_mismatch_description(
            matcher, always_matches(),
            "The description was <This is a description>.")

        assert_that(match_result, is_(False))
    def test_not_matches__correct_description(self, never_matches, anything):
        """
        Dude

        Here we pass a matcher that never matches and check that the description is correct"""

        matcher = matches(anything).with_description("This is a description")
        match_result = matcher._matches(never_matches())

        assert_description(
            matcher, "A matcher that matches the item "
            "with the description: <This is a description>.")

        assert_mismatch_description(
            matcher, never_matches(), "The matcher did not match.")

        assert_that(match_result, is_(False))
예제 #8
0
 def test_with_no_kwarg(self, number):
     assert_that(my_number(4), matches(number))
예제 #9
0
 def test_with_a_kwarg(self):
     assert_that(
         my_number(4, type_=MyNumber),
         matches(
             MyNumber(4)).with_description('<4>; an instance of MyNumber.'))
 def test_simple_matches(self, always_matches):
     assert_that(
         always_matches("hello"),
         matches("hello").with_description("This is a description")
     )