Если я Вы хотели протестировать такой код, то решение (для Python 2.7.11) ниже.
import unittest
import mock
class B(object):
def some1(self):
print 'some 1'
class C(object):
def some2(self):
print 'some 2'
class A(object):
def __init__(self):
self.b = B()
self.c = C()
def just_do_it(self):
print 'Hello'
self.b.some1()
self.c.some2()
class BMock(object):
def some1(self):
print 'mock.some 1'
class CMock(object):
def some2(self):
print 'mock.some 2'
class ATestCase(unittest.TestCase):
@mock.patch('main.B')
@mock.patch('main.C')
def test_success_just_do_it(self, c, b):
b.side_effect = BMock
c.side_effect = CMock
a = A()
a.just_do_it()