def test_pending(self): callback = raw_mock() @pending def test_failure(self): callback('a') raise RuntimeError, "something went wrong!" self.assert_(self.run_method(test_failure).wasSuccessful()) assert_desc(self.output.called.with_('[[[ PENDING ]]] ... ')) @pending("reason") def test_failure_with_reason(self): assert False callback('b') self.assert_(self.run_method(test_failure_with_reason).wasSuccessful()) assert_desc(self.output.called.with_('[[[ PENDING ]]] (reason) ... ')) @pending def test_successful_pending_test(self): assert True callback('c') self.assertEqual(self.run_method(test_successful_pending_test).wasSuccessful(), False) assert_desc(self.output.called.with_('test_successful_pending_test PASSED unexpectedly ')) self.assertEqual(mock(callback).called.exactly(2).times.get_calls(), [('a',), ('c',)])
def test_should_ignore_with_description(self): callback = raw_mock() mock(callback).is_expected.exactly(0).times @ignore('not done yet') def test_failure(self): callback('a') self.assert_(self.run_method(test_failure).wasSuccessful()) assert_desc(self.output.called.with_('[[[ IGNORED ]]] (not done yet) ... '))
def test_ignore(self): callback = raw_mock() mock(callback).is_expected.exactly(0).times @ignore def test_failure(self): callback('a') self.assert_(self.run_method(test_failure).wasSuccessful()) assert_desc(self.output.called.with_('[[[ IGNORED ]]] ... '))
def test_constructor(self): mock = raw_mock() wrapper = mock_wrapper(mock) self.assertFalse(wrapper.called, "called not initialised correctly") self.assertTrue(wrapper.called.exactly(0), "call_count not initialised correctly") self.assertEquals(wrapper.call_list, []) self.assertEquals(wrapper._children, {}) self.assertEquals(wrapper.action, None) self.assertEquals(wrapper.name, 'unnamed mock') wrapper.name = 'lil bobby mock'
def test_name_as_first_arg_in_constructor(self): wrapper = mock_wrapper(raw_mock("li'l mocky")) self.assertEqual(wrapper.name, "li'l mocky")