lundi 18 novembre 2019

How to check call count per request type with requests_mock?

I'm trying to use requests_mock in my tests to mock a function making multiple HTTP requests with different methods. So I do something like this:

with requests_mock.mock() as mock:
    mock.get(get_url, text='text')
    mock.post(post_url, status_code=200, json={'foo': 'bar'})
    test_function()
    assert mock.call_count == 2

This works fine, however it doesn't tell me which HTTP methods were called. Is there any way I can check that?

Aucun commentaire:

Enregistrer un commentaire