def test_should_delegate_and_invert_matches_calls(self): actual_mock = mock() matcher_mock = mock(Matcher) when(matcher_mock).matches(any_value()).thenReturn(True) matcher = NegatedMatcherDecorator(matcher_mock) self.assertFalse(matcher.matches(actual_mock)) verify(matcher_mock).matches(actual_mock)
def test_should_delegate_accept_calls(self): actual_mock = mock() matcher_mock = mock(Matcher) when(matcher_mock).accepts(any_value()).thenReturn(True) matcher = NegatedMatcherDecorator(matcher_mock) self.assertTrue(matcher.accepts(actual_mock)) verify(matcher_mock).accepts(actual_mock)
def test_should_invoke_describe_negated_when_describe_is_called(self): actual_mock = mock() matcher_mock = mock(Matcher) when(matcher_mock).describe_negated(any_value()).thenReturn("spam") matcher = NegatedMatcherDecorator(matcher_mock) self.assertEquals("spam", matcher.describe(actual_mock)) verify(matcher_mock).describe_negated(actual_mock) verify(matcher_mock, 0).describe(actual_mock)