Problem When Unit Testing with PMock
Peter Hansen
peter at engcorp.com
Sun Feb 27 10:56:44 EST 2005
steven at lczmsoft.com wrote:
>>def mockit(): raise StopIteration
>>now pass mockit()
>
>
> but it behaviors differenctly when pass in a mockit() and pass in an
> iterator with empty. so i think the code emulates nothing.
Is it possible that what you really need is a generator function
instead of just a regular one?
def mockit():
raise StopIteration
yield None
(The presence of the yield will let the compiler generate the
proper code for this to be a generator, but it will never
actually hit the yield statement when it executes...)
Just a thought.
-Peter
More information about the Python-list
mailing list