[TIP] testing class properties and internal methods

Fuzzyman fuzzyman at voidspace.org.uk
Tue Mar 6 02:20:58 PST 2007

Max Ischenko wrote:

> On 3/6/07, *Michael Foord* <fuzzyman at voidspace.org.uk
> <mailto:fuzzyman at voidspace.org.uk>> wrote:
>     It is often easier to specify public API behaviour in terms of calling
>     down to private methods - and then mock out these private methods
>     in the
>     test of the public API. The private methods can then be tested
>     separately. 
> In a situation like this, I often prefer to factor out these private
> methods into class on it own which is then tested separatedly.
> Delegation is cool.
When I say 'Public API', I mean the API of classes that are to be
consumed directly *within our own application* (i.e. by the other
classes and modules).

We do have a scripting API which will be 'truly public', for which we
will probably implement proxy objects that only expose the public API (a
workaround since Python lacks real private members...).


> Max.
> maxischenko.in.ua <http://maxischenko.in.ua> // www.developers.org.ua
> <http://www.developers.org.ua> // exception.org.ua
> <http://exception.org.ua> -- Python seminars in Kiev

More information about the testing-in-python mailing list