def test_not_called_fail(desc): matcher = not_called() expected = "was called 1 times with ('foo', )" mock = Mock() mock('foo') ok = matcher.matches(mock, desc) assert_that(ok, equal_to(False)) assert_that(str(desc), equal_to(expected))
def test_not_called_fail(): expected = ''' Expected: Mock called with ANYTHING 0 times but: was called 1 times ''' mock = Mock() mock('foo') with assert_raises(AssertionError) as e: assert_that(mock, not_called()) assert_that(str(e.exception), equal_to(expected))
def test_not_called_ok(): mock = Mock() assert_that(mock, not_called())
def test_not_called_description(desc): matcher = not_called() expected = 'Mock called <0> times with ANYTHING' matcher.describe_to(desc) assert_that(str(desc), equal_to(expected))
def test_not_called_ok(): matcher = not_called() mock = Mock() ok = matcher.matches(mock) assert_that(ok, equal_to(True))