'TestCase.patch' has proven itself to be very convenient and readable in Twisted.
self.patch(sys, 'time', newfoo)
is more readable than:
self.addCleanup(monkey.patch, sys, 'time', newfoo)
or even
self.addCleanup(monkey.patch(sys.time, newfoo))
And if monkey.patch can be implemented in the last way (I'm not so sure), then TestCase.patch could be written as:
self.patch(sys.time, newfoo)
I don't feel strongly about it.
'TestCase.patch' has proven itself to be very convenient and readable in Twisted. addCleanup( monkey. patch, sys, 'time', newfoo) addCleanup( monkey. patch(sys. time, newfoo))
self.patch(sys, 'time', newfoo)
is more readable than:
self.
or even
self.
And if monkey.patch can be implemented in the last way (I'm not so sure), then TestCase.patch could be written as: patch(sys. time, newfoo)
self.
Which makes the intent very clear.