[TIP] Mock objects in testing object composition?

Benji York benji at benjiyork.com
Tue Apr 24 13:45:42 PDT 2007


Julius Lucks wrote:
> I would like 
> to separate Grid tests from dependance on Tile so that later on down the 
> road when I change the Tile class and break it, then my Grid tests don't 
> start to fail for this reason.  Is this not a good way of thinking?

It sounds ideal, but like so many ideals its cost is likely greater than 
the benefit.

I wouldn't worry about it.  One day your Tile and Grid tests start 
failing, you look at one or the other and realize pretty quickly that 
Tile is at fault, you fix Tile and Grid is happy too.  Not to mention 
that you making changes to Tile is what caused the tests to start 
failing, so you'll have a pretty good idea what happened.
-- 
Benji York
http://benjiyork.com



More information about the testing-in-python mailing list