#16235: Test client flatens POST data ------------------------------------+----------------------------------- Reporter: emdonahu@… | Owner: nobody Type: Bug | Status: new Milestone: | Component: Testing framework Version: 1.3 | Severity: Normal Keywords: test client, querydict | Triage Stage: Unreviewed Has patch: 1 | Easy pickings: 0 UI/UX: 0 | ------------------------------------+----------------------------------- Under normal production conditions, request.POST returns a QueryDict corresponding to the query parameters, like so: {{{ <QueryDict: {u'my_key': [u'my_value']}> }}}
However, when running a post request from the test client via {{{ python manage.py test }}} the post data gets flattened into a single string that is unparsable by the QueryDict, resulting in this: {{{ <QueryDict: {u"{'my_key': ['my_value']}": [u'']}> #the whole parameter dictionary is flattened into a string }}} Currently, the data dict is serialized by the smart_str function, which only seems to be intended for encoding strings. The result is an encoded but unformatted serialized post_data string that eventually reaches the QueryDict constructor, but does not present a format that QueryDict respects. If this not in fact the intended behavior, the most straight- forward fix would seem to be urlencoding the data dict prior to serialization. A patch representative of this suggestion is attached. For further presentation of the issue, refer to [http://stackoverflow.com/questions/6315960/djangos-querydict-bizarre- behavior-bunches-post-dictionary-into-a-single-key]. -- Ticket URL: <https://code.djangoproject.com/ticket/16235> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.