def test_conjure_response_with_spec(self, conjure_response): conjure_response.return_value = None knight = Knight('Foo') knight.query('foo') # This is actually nonsense, and should fail! conjure_response.assert_called_with_nonsense('foo')
def test_conjure_response(self, conjure_response): conjure_response.return_value = None knight = Knight('Foo') knight.query('foo') # Notice these all test pretty much the same thing conjure_response.assert_called_with('foo') conjure_response.assert_called_once_with('foo') conjure_response.assert_any_call('foo') # Also, notice these all test pretty much the same thing self.assertEqual(conjure_response.called, True) self.assertEqual(conjure_response.call_count, 1) calls = [call('foo')] conjure_response.assert_has_calls(calls) # But what about this? conjure_response.assert_called_once() conjure_response.assert_called_once('foo') # Or this? conjure_response.assert_called_twice_with('foo')
def test_knights_tell_truth(self): knight = Knight('Foo') self.assertEqual(True, knight.tell_truth())
def test_knight_response(self): knight = Knight('Foo') r = knight.query('foo') self.assertEqual(r, u'We are of the same kind.')