-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aiohttp request and response normalization #205
base: master
Are you sure you want to change the base?
aiohttp request and response normalization #205
Conversation
def test_aiohttp_request_normalization(): | ||
from aiohttp.test_utils import make_mocked_request | ||
|
||
raw_request = make_mocked_request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to this since it is from the formal aiohttp
tools, however, it is pretty easy to do async testing with pytest.
@pytest.mark.asyncio
async def my_async_test():
response = await ....
Since we have the httpbin
fixture which runs a local webserver it should be pretty easy to generate a real request/response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback. I would also have to use the compatibility utils from asyncio to not get a syntax error in Python < 3.5.
I may try this if I find the time, since the aiohttp.test_utils
API is marked as provisional, which may break this test in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is tricky, since the tests need to pass for Python 2.
An async
keyword just triggers a syntax error, with no chance for pytest to even skip the test. Even if I use the Python <3.5 @asyncio.coroutine
syntax, I get a syntax error due to the yield from
statement.
It looks to me like the only way to get actual async tests to run for newer versions is to move them to their own file, and ignore them during test collection, e.g. like this: pytest-dev/pytest#2817 (which may have further side effects; after all, we don't want to skip any other test files on syntax errors).
@pipermerriam does this still seem worth exploring to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New maintainer here. Yes, please explore that!
At this point, with Python 2 being officially unsupported in less than a year, if you or somebody else wants to rewrite this to require Python 3.6+, I would accept that. |
Support validating aiohttp requests and responses!
CI and linter are green. Also updated the docs.
The test cases mock requests and responses, rather than make actual requests, since it's not trivial to get async code running in the test suite.
Looking forward to your feedback.