jeudi 9 juillet 2015

Mocking recursion method

For example we have recursion:

def method():
   method()

How to mock that recursion will not happened? If I mock method that I want to test, how can I enter method if method will return mock object?

class test_Method(unittest.TestCase):
    def test_recursion(self):
         instance.method = Mock()
         instance.method.assert_called_once_with()

I didn't notice any help in the documentation. Or did I just miss it?

Aucun commentaire:

Enregistrer un commentaire