Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFix BytesWarning in test_schemas.py #6638
Conversation
|
Would it make sense to just test with a byte string instead of decoding the response assert b"You do not have permission to perform this action." in response.content |
|
Yup. Either way works as an effective assert. |
When Python is run with the -b command line argument, the following
warning was previously emitted:
tests/test_schemas.py::test_schema_handles_exception
.../django-rest-framework/tests/test_schemas.py:1361: BytesWarning: str() on a bytes instance
assert "You do not have permission to perform this action." in str(response.content)
To fix this warning decode the bytes with an explicit encoding.
For details on the -b command line argument, see:
https://docs.python.org/3/using/cmdline.html#cmdoption-b
|
Switched to the bytes literal approach. |
|
|

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

When Python is run with the -b command line argument, the following
warning was previously emitted:
tests/test_schemas.py::test_schema_handles_exception
.../django-rest-framework/tests/test_schemas.py:1361: BytesWarning: str() on a bytes instance
assert "You do not have permission to perform this action." in str(response.content)
To fix this warning decode the bytes with an explicit encoding.
For details on the -b command line argument, see:
https://docs.python.org/3/using/cmdline.html#cmdoption-b