I’ve realized that test code difficult to write and read is sometimes a code smell. It could mean the test code is wrong or the SUT (subject under test) itself is wrong. I’ve got myself thinking of how to test a method X of a class C which is calling another method Y within the same class, but avoiding or stubbing the call to Y.
Here are some ideas to work around this issue (python code).
The SUT:

class MyClass:        
    def substractOne(self, arg1):
        return arg1 -1
        
    def calculate(self, x, y):
        result = x * y
        return self.substractOne(result)

Basic tests:

class SomeTests(mocker.MockerTestCase):
    def test_substractOne(self):
        instance = MyClass()
        result = instance.substractOne(10)
        self.assertEqual(result, 9)
       
    def test_calculate(self):
        instance = MyClass()
        result = instance.calculate(1, 5)
        self.assertEqual(result, 4)

So far so good, but…. what would happen if “substractOne” was “saveCustomerMoney”… would you let your test change a bank account?. No!. If we already have a separate test for “saveCustomerMoney”, we just want to test “calculate” (which would have a differente name, of course).
From now bear in mind that we need to test “calculate” avoiding the call to “substractOne”.
Steve Freeman wrote that composition would be the solution. Composition is a refactoring. Composition means in this context, to extract classes from MyClass encapsulating methods regarding their functionality. Ask yourself this: “do all those methods belong in that class, or are they for totally different proposes?”. The solution in code:
The new SUT:

class MathOperation():
    def __init__(self, substract, multiply):
        self.substract = substract
        self.multiply = multiply
        
    def calculate(self, x, y):
        result = self.multiply.simpleMultiply(x, y)
        return self.substract.substractOne(result)              

class Multiply():
    def simpleMultiply(self, x, y):
        return x * y
    
class Substract():
    def substractOne(self, arg):
       return arg -1 

The test: (remember we want to avoid calls to substractOne)

    def test_MathOperation(self):
        mockSubstract = self.mocker.proxy(Substract)
        x = 5
        mockSubstract.substractOne(x)
        self.mocker.result(x)
        
        self.mocker.replay()
        
        multiply = Multiply()
        instance = MathOperation(mockSubstract, multiply)
        result = instance.firstMethod(1, 5)
        self.assertEqual(result, 5)

Right, but if you don’t need composition? If both methods belong in the same class according to the domain model?. You can use the “extract method” refactoring so that calculate would be like this:

def calculate(self, x, y):
    result = self.simpleMultiply(x, y)
    return self.substractOne(result)   

And now you can test simpleMultiply and substractOne separately.
But say I still want to call “calculate” in a test to make sure it does not blow up. That would call substractOne and we can’t allow that in the test. Polymorphism is a good answer.
The SUT:

class MyClass:        
    def substractOne(self, arg1):
        return arg1 -1
        
    def calculate(self, x, y):
        result = x * y
        return self.substractOne(result)

The test:

def test_calculate(self):
        class ChildClass(MyClass):
            def substractOne(self, arg1):
                return arg1
            
        instance  = ChildClass()
        result = instance.calculate(1, 5)
        self.assertEqual(result, 5)  

Actually the mock framework can do this for us too but the code above is probably easier to understand.
But what do we do if the method is recursive?. You can modify the method to keep the functionality with an iterative implementation. In my opinion that is too much work. You can use the mock framework to exercise the SUT in the first call and mock the first and further recursive calls.

Thanks to the testdrivendevelopment mailing list, it is a really good place for the TDD community.