Best way to test class methods without running __init__

Posted by KenFar on Stack Overflow See other posts from Stack Overflow or by KenFar
Published on 2010-05-18T17:08:03Z Indexed on 2010/05/18 17:10 UTC
Read the original article Hit count: 162

Filed under:
|

I've got a simple class that gets most of its arguments via init, which also runs a variety of private methods that do most of the work. Output is available either through access to object variables or public methods.

Here's the problem - I'd like my unittest framework to directly call the private methods called by init with different data - without going through init.

What's the best way to do this?

So far, I've been refactoring these classes so that init does less and data is passed in separately. This makes testing easy, but I think the usability of the class suffers a little.

© Stack Overflow or respective owner

Related posts about python

Related posts about unit-testing