[TIP] mocking out mixins and subclasses

Nate Lowrie solodex2151 at gmail.com
Mon Mar 5 10:30:15 PST 2007


I have several mixin classes that are subclassed by other classes.  I
am unit testing the mixin classes on there own. Some of the classes
that subclass these mixins call the mixin functions in some of the
methods.  I know that I can rebind the methods to mocked function
after I instantiate an object but there are some calls to the mixin
methods in the init section as well.  Ideally, I would like to mock
the mixin before creating any objects.

How are other people handling unit testing for mixins and objects
using the mixin?  Is there an easy way to do this that I am
overlooking?

Cheers,

Nate L.



More information about the testing-in-python mailing list