Using webapp2 I create unit tests for a form where there are flags for votes, so for the vote
field you can put several values ββand they are retrieved via request.POST.getall('vote')
:
<input type="checkbox" name="vote" value="Better"> <input type="checkbox" name="vote" value="Faster"> <input type="checkbox" name="vote" value="Stronger">
In unit test, I tried passing a list:
response = app.get_response('/vote', POST={'vote': [u'Better', u'Faster', u'Stronger']}, headers=[('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8')] )
But it looks like it's just converted to a string:
votes = self.request.POST.getall('vote') # => [u"[u'Better', u'Faster', u'Stronger']"]
How to pass several values ββfor vote
, which will be obtained as a list through request.POST.getall()
?
source share