MockObject Suport For unittest.TestCase

Matt Russell matt at teaphoo.fsnet.co.uk
Fri Mar 21 10:51:33 CET 2003


Many appologies for getting yout name wrong Michael, I am all over the
place this morning :(


mcherm at mcherm.com wrote in message news:<mailman.1048186475.2042.python-list at python.org>...
> 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