python check if a method is called without mocking it away

You can set the Mock.side_effect to be the original method. from unittest.mock import MagicMock class A(): def tmp(self): print(“hi”) def b(a): a.tmp() a = A() a.tmp = MagicMock(side_effect=a.tmp) b(a) a.tmp.assert_called() When side_effect is a function (or a bound method in this case, which is a kind of function), calling the Mock will also call the … Read more

Mock entire python class

First it is very important to understand that you always need to Mock where it the thing you are trying to mock out is used as stated in the unittest.mock documentation. The basic principle is that you patch where an object is looked up, which is not necessarily the same place as where it is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)