#30089: TestClient doesn't accept data with duplicate keys (SELECT multiple)
-----------------------------------+--------------------------------------
Reporter: Adam Gilman | Owner: nobody
Type: Uncategorized | Status: closed
Component: Testing framework | Version: 2.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Comment (by Adam Gilman):
Apologies, typo in my original test. Good catch. Updated test and failure
below
{{{#!python
def test_post_multi_select(self):
"POST SELECT multiple data to a view"
post_data = QueryDict(mutable=True)
post_data.update({'value':37})
post_data.update({'value':38})
response = self.client.post('/post_view/', post_data)
# Check some response details
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['data'], ['37', '38'])
self.assertEqual(response.templates[0].name, 'POST Template')
self.assertContains(response, 'Data received')
}}}
{{{#!bash
FAIL: test_post_multi_select (test_client.tests.ClientTest)
POST SELECT multiple data to a view
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/dev2/.pyenv/versions/3.7.0/lib/python3.7/unittest/case.py",
line 59, in testPartExecutor
yield
File "/Users/dev2/.pyenv/versions/3.7.0/lib/python3.7/unittest/case.py",
line 615, in run
testMethod()
File "/Users/dev2/Documents/GitHub/django/tests/test_client/tests.py",
line 113, in test_post_multi_select
self.assertEqual(response.context['data'], ['37', '38'])
File "/Users/dev2/.pyenv/versions/3.7.0/lib/python3.7/unittest/case.py",
line 839, in assertEqual
assertion_func(first, second, msg=msg)
File "/Users/dev2/.pyenv/versions/3.7.0/lib/python3.7/unittest/case.py",
line 832, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: '38' != ['37', '38']
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30089#comment:3>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.206fc76b65d3175836e5df715cd666ee%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.