#34947: assertContains fails when there is unicode in the response json
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
ideesnoires |
Type: Bug | Status: new
Component: Testing | Version: 4.2
framework | Keywords: unicode, testing,
Severity: Normal | assertcontains
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
#views.py
class Umlaut(View):
def get(self, request):
return JsonResponse({"uml": "äuuuß"})
#tests.py
class UmlautTest(TestCase):
def test_contains(self):
response = self.client.get('/')
self.assertContains(response, 'ä')
# produces:
======================================================================
FAIL: test_contains (app.tests.UmlautTest.test_contains)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/markus/dev/testcase/p/app/tests.py", line 6, in
test_contains
self.assertContains(response, 'ä')
File "/Users/markus/Library/Caches/pypoetry/virtualenvs/testcase-
H5bBokyv-py3.12/lib/python3.12/site-packages/django/test/testcases.py",
line 660, in assertContains
self.assertTrue(
AssertionError: False is not true : Couldn't find 'ä' in response
----------------------------------------------------------------------
Ran 1 test in 0.002s
FAILED (failures=1)
#but is succesful when checking for 'uuu'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34947>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018ba5007cc3-e3776fdf-0ca4-4842-879a-9c805e4adfce-000000%40eu-central-1.amazonses.com.