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
Fix test_utils.make_mocked_request
behaviour for empty payload
#7168
base: master
Are you sure you want to change the base?
Conversation
@@ -632,7 +633,7 @@ def make_mocked_request( | |||
protocol.writer = writer | |||
|
|||
if payload is sentinel: | |||
payload = mock.Mock() | |||
payload = EMPTY_PAYLOAD |
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.
Feels to me like everything here should be a mock. Maybe instead we should autospec it? That should ensure it gets an appropriate mock with the correct methods.
payload = EMPTY_PAYLOAD | |
payload = create_autospec(StreamResponse, spec_set=True, instance=True) |
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.
Same should really be done to all the rest of this code... Would make the code safer and more maintainable.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7168 +/- ##
=======================================
Coverage 97.37% 97.37%
=======================================
Files 106 106
Lines 31093 31098 +5
Branches 3875 3875
=======================================
+ Hits 30278 30283 +5
Misses 613 613
Partials 202 202
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
What do these changes do?
Fixes #7167
In case of empty payload when initialized, it now assigns the payload as
EMPTY_RESPONSE
instance ofEmptyStreamReader
available via aiohttp/streams.pyAre there changes in behavior for the user?
No
Related issue number
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.