Добавить
Уведомления

Python mox mock UnitTest MultipleTimes Example

http://fosshelp.blogspot.in/2014/11/python-mox-mock-unit-test-multipletimes.html with pymox mock object framework for Python for unittest 1) Without MultipleTimes class Time: def get_time(): pass import mox ## Start recording (start record mode) t=mox.MockObject(Time) t.get_time().AndReturn("you can call me only once") ## Stop recording (start reply mode) mox.Replay(t) t.get_time() t.get_time() * Here You can call the method "get_time" only once 2) With MultipleTimes class Time: def get_time(): pass import mox t=mox.MockObject(Time) t.get_time().MultipleTimes().AndReturn("you can call me multiple times") mox.Replay(t) t.get_time() t.get_time() * Here You can call the method "get_time" multiple times

12+
17 просмотров
2 года назад
12+
17 просмотров
2 года назад

http://fosshelp.blogspot.in/2014/11/python-mox-mock-unit-test-multipletimes.html with pymox mock object framework for Python for unittest 1) Without MultipleTimes class Time: def get_time(): pass import mox ## Start recording (start record mode) t=mox.MockObject(Time) t.get_time().AndReturn("you can call me only once") ## Stop recording (start reply mode) mox.Replay(t) t.get_time() t.get_time() * Here You can call the method "get_time" only once 2) With MultipleTimes class Time: def get_time(): pass import mox t=mox.MockObject(Time) t.get_time().MultipleTimes().AndReturn("you can call me multiple times") mox.Replay(t) t.get_time() t.get_time() * Here You can call the method "get_time" multiple times

, чтобы оставлять комментарии