ViewTestCases doesn't handle unicode correctly #415
Labels
type: bug
Something isn't working as expected
type: housekeeping
Changes to the application which do not directly impact the end user
Proposed Changes
Throughout
nautobot/utilities/testing/views.py
, HTTP response content is cast to an ASCII string viastr(response.content)
. This results in any unicode characters being rendered as escape sequences (e.g.Region ɑ
is rendered asRegion \\xc9\\x91
), which can result in test failures if the string being searched for in the content is mangled in this way and so is not detectable in the content.A more correct pattern would be to use
response.content.decode(response.charset)
as this will correctly render Unicode and allow tests using Unicode strings to pass.Justification
It's 2021, we shouldn't be enforcing ASCII anywhere, much less in our tests.
The text was updated successfully, but these errors were encountered: