-
-
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
Fix a test for HTTPUnauthorized with a Unicode string body argument #5731
Conversation
…web_response.py when accessing text
I'm not sure how to fix mypy here, should I move value property to StringPayload and say that it returns str? |
aiohttp/web_response.py
Outdated
@@ -697,6 +697,8 @@ def body( | |||
def text(self) -> Optional[str]: | |||
if self._body is None: | |||
return None | |||
if isinstance(self._body, 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.
Could you explain this bit? I expected the fix to be in the exception initializer.
Now that I look at it, I think that the test is wrong and everything works correctly on 3.8. The reason is, on master, the response from I'll look tomorrow if the test can be rewritten or should be deleted entirely. |
I think I should remove the last line for the test, where it access def test_unicode_text_body_unauthorized() -> None:
"""
Test that HTTPUnauthorized can be initialized with a string.
"""
with pytest.warns(
DeprecationWarning, match="body argument is deprecated for http web exceptions"
):
resp = web.HTTPUnauthorized(body="text")
assert resp.status == 401 |
What do these changes do?
Allows previous behavior when constructing HTTPUnauthorized with a body argument as a string
Are there changes in behavior for the user?
Users are now able to send HTTPUnauthorized response with a string
#5657
This commit fixes #5657
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.