def test_fails_second_time(self):
     self.raw_api.do_it.side_effect = [
         InvalidAuthToken('message', 'code'),
         InvalidAuthToken('message', 'code'),
     ]
     with self.assertRaises(InvalidAuthToken):
         self.session.do_it()
Exemple #2
0
 def __call__(self, *args, **kwargs):
     if self.__called:
         return self.__original_function(*args, **kwargs)
     self.__called = True
     raise InvalidAuthToken('message', 401)
 def test_works_second_time(self):
     self.raw_api.do_it.side_effect = [
         InvalidAuthToken('message', 'code'),
         'ok',
     ]
     self.assertEqual('ok', self.session.do_it())