I have a simple class that gets most of its arguments through init, which also runs many private methods that do most of the work. The output is available either through access to object variables or to public methods.
Here's the problem - I would like my unittest framework to directly invoke private methods called init with different data, without passing init.
What is the best way to do this?
So far, I have refactored these classes so that init does less and the data is transferred separately. This makes testing easier, but I think the usability of the class suffers a bit.
EDIT: An example solution based on Ignacio's answer:
import types
class C(object):
def __init__(self, number):
new_number = self._foo(number)
self._bar(new_number)
def _foo(self, number):
return number * 2
def _bar(self, number):
print number * 10
MyC = C(8)
MyC = object.__new__(C)
MyC._bar(8)