예제 #1
0
 def test_call_count(self):
     s = Spy('str')
     s.upper()
     self.assertEqual(1, s.upper.call_count())
     s.lower()
     self.assertEqual(1, s.upper.call_count())
     s.upper()
     self.assertEqual(2, s.upper.call_count())
예제 #2
0
 def test_returns_when_func_called(self):
     spy = Spy('string')
     spy.upper.returns(22)
     self.assertEqual(22, spy.upper())
예제 #3
0
 def test_was_exact_func_called(self):
     spy = Spy('string')
     spy.upper(1)
     self.assertTrue(spy.was_exact_function_called('upper', 1))
예제 #4
0
 def test_was_func_called_with_arg(self):
     spy = Spy('string')
     spy.upper(1)
     self.assertTrue(spy.was_function_with_argument_called('upper', 1))
예제 #5
0
 def test_all_calls(self):
     spy = Spy('string')
     self.assertEqual([], spy.all_calls())
     spy.upper()
     self.assertTrue(len(spy.all_calls()) == 1)
예제 #6
0
 def test_can_call_str_func_on_spy(self):
     s = "string"
     spy = Spy(s)
     spy.upper()
예제 #7
0
 def test_all_calls_args_flatten(self):
     s = Spy('str')
     s.replace('t', 'T')
     s.upper()
     s.lower(1)
     self.assertEqual(['t', 'T', 1], s.all_calls_args_flatten())
예제 #8
0
 def test_all_calls_args(self):
     s = Spy('str')
     s.replace('t', 'T')
     s.upper()
     s.lower(1)
     self.assertEqual([('t', 'T'), (), (1, )], s.all_calls_args())