I have a class similarly structured to this:
class TestClass:
def a(self):
pass
def b(self):
self.a()
I want to test if running TestClass().b() successfully calls TestClass().a():
class TestTestClass(unittest.TestCase):
def test_b(self):
with patch('test_file.TestClass') as mock:
instance = mock.return_value
TestClass().b()
instance.a.assert_called()
However, it fails because a isn't called. What am I doing wrong? I went through the mock documentation and various other guides to no avail.
Thanks!
ainstead (e.g.patch("test_file.TestClass.a")).