Encountered on Ubuntu 22.04.
aiohttp version 3.8.4
aioresponses version 0.7.4
I encountered this when running python tests with pytest.
Consider the following file test_method_case_bug.py (note that I am supplying a lowercase parameter "get" to the session.request):
import pytest
import aiohttp
from aioresponses import aioresponses
@pytest.fixture
def mock_aioresponse():
with aioresponses() as m:
yield m
async def make_request():
async with aiohttp.ClientSession() as session:
async with session.request('get', 'http://localhost') as response:
return response.ok
@pytest.mark.asyncio
async def test_request(mock_aioresponse):
mock_aioresponse.get('http://localhost')
await make_request()
mock_aioresponse.assert_any_call('http://localhost')
If run with the command pytest test_method_case_bug.py, you will see that the assertion mock_aioresponse.assert_any_call('http://localhost') fails because it is expecting the method to be uppercase GET not lowercase get.
Encountered on Ubuntu 22.04. aiohttp version 3.8.4 aioresponses version 0.7.4
I encountered this when running python tests with pytest. Consider the following file
test_method_case_bug.py
(note that I am supplying a lowercase parameter "get" to thesession.request
):If run with the command
pytest test_method_case_bug.py
, you will see that the assertionmock_aioresponse.assert_any_call('http://localhost')
fails because it is expecting the method to be uppercaseGET
not lowercaseget
.I suggest assigning the
self.requests
keys with anupper()
call. i.e. change https://github.com/pnuckowski/aioresponses/blob/master/aioresponses/core.py#L516 to bekey = (method.upper(), url)