unit testing class hierarchies

Ben Finney ben+python at benfinney.id.au
Tue Oct 2 18:30:19 EDT 2012


Ulrich Eckhardt <ulrich.eckhardt at dominolaser.com> writes:

> I want test_base() to be run as part of both TestD1 and TestD2,
> because it tests basic functions provided by both classes D1 and D2.

It sounds, from your description so far, that you have identified a
design flaw in D1 and D2.

The common functionality should be moved to a common code point (maybe a
base class of D1 and D2; maybe a function without need of a class). Then
you'll have only one occurrence of that functionality to test, which is
good design as well as easier test code :-)

-- 
 \      “When I was a little kid we had a sand box. It was a quicksand |
  `\           box. I was an only child... eventually.” —Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list