MockObject Suport For unittest.TestCase
mcherm at mcherm.com
mcherm at mcherm.com
Thu Mar 20 13:46:52 EST 2003
Matt:
GREAT CONTRIBUTION!
I think that mock objects is a feature that could be very useful, and
a handy way to build them inside the unittest module sounds like a
greate idea. And we appreciate your effort to contribute!
I haven't finished looking over your patch yet, but I have a couple
of suggestions right fron the beginning.
(1) I would change self.called (which is private storage for the mock
object) to something like self.__mockObject_called to reduce the chance
of an unfortunate name collision.
(2) In MockFactory.__new__ I would try to check for classes implementing
custom __getattr__, and __getattribute__ methods, and handle those
specially (probably by raising an exception claiming that the class
can't be mocked).
I'm sure there'll be other suggestions from other people, and perhaps
some more from me if I get more time.
-- Michael Chermside
More information about the Python-list
mailing list