Python Mock Cookbook
2023. 5. 17. 17:32ㆍ서버 프로그래밍
클래스 메소드의 Mock을 처리하는 방법을 찾다가 괜찮은 레퍼런스를 발견했다.
https://chase-seibert.github.io/blog/2015/06/25/python-mocking-cookbook.html
Python Mock Cookbook
The python mock library is one of the awesome things about working in Python. No matter what code you’re unit testing, it’s possible to mock out various pieces with very little test code. That being said, it’s sometimes difficult to figure out the ex
chase-seibert.github.io
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
...