Open lecardozo opened 4 years ago
Please try
@pytest.mark.gen_test
async def test_api(http_client, base_url):
with patch("path.to.handler.dummy_function", mocked_dummy):
response = await http_client.fetch(base_url + "/endpoint")
# run asserts...
I'm currently trying to mock a coroutine that is called inside the
.get
method of a handler. Let's call it,dummy_function
.My initial approach for mocking this function was to apply the mock on the
app
fixtureWhen I run this, the patch doesn't work and the original dummy_function is not replaced. Is this the right approach?
Thanks!