[TIP] mocking out mixins and subclasses

Kumar McMillan kumar.mcmillan at gmail.com
Mon Mar 5 11:07:14 PST 2007


you might find that you get better coverage and simpler tests if you
spend some time setting up state so it can all be tested as real
objects.  This may slow things down at first but you can always tune
bottlenecks later on.  However, if you are really really convinced
that you need to use mock mixin objects I guess you could always edit
TheMainClass.__bases__ !

On 3/5/07, Nate Lowrie <solodex2151 at gmail.com> wrote:
> 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.
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>



More information about the testing-in-python mailing list