Python Mock Cookbook
2023. 5. 17. 17:32ㆍ서버 프로그래밍
클래스 메소드의 Mock을 처리하는 방법을 찾다가 괜찮은 레퍼런스를 발견했다.
https://chase-seibert.github.io/blog/2015/06/25/python-mocking-cookbook.html
Class MethodsPermalink
What about a @classmethod on a class? It’s the same as a method.
@mock.patch('myapp.app.Car.for_make')
def test_classmethod(self, mock_for_make):
new_car = Car()
new_car.make = 'Chevy'
mock_for_make.return_value = new_car
...