-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
make_mocked_request() behavior is broken when no payload is specified #7167
Labels
Comments
rahulnht
changed the title
[make_mocked_request()] behavior is broken when no payload is specified
make_mocked_request() behavior is broken when no payload is specified
Jan 13, 2023
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When unit testing handler/middleware behavior with a request created via make_mocked_request() method without specifying payload, ran into issues with reading its content inside handler.
Looking at the source, found problem with the an default empty mock that is assigned if payload is not explicitly specified.
To Reproduce
Run the following sample minimal script that reproduces the behavior.
Expected behavior
When running as web_app, the request to / sends 200.
When running via test, it fails. Ideally the payload should be initialized as empty so that if awaited, empty body is returned inside handler.
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
Ubuntu 22.04.1
Related component
Server
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: