📜  python mokeypatch asser 调用 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:02.636000             🧑  作者: Mango

代码示例1
from unittest import mock
import requests

...

@mock.patch('requests.Session.get')
def test_api_session_get(mocked, api_session) -> None:
    def mock_get(*args, **kwargs):
        return MockResponse()

    mocked.side_effect = mock_get
    response = api_session.get('endpoint/') 
    ...
    mocked.assert_called_with(
        'endpoint/',
        headers={
            'user-agent': 'blah',
        },
    )