Friday, February 21, 2014

Django test client encoding of JSON Booleans

I'm using Django version 1.5.5. Here is a short snippet of the test I'm writing:

from django.test import TestCase

class MyTest(TestCase):

  def my_test(self):
    url = ... location of my view ...
    self.client.post(url, data={'active': False}, format='json')


The problem I'm running into is that when I inspect request.POST inside my view, I get: {'active': [u'False']}. The workaround I have right now is to use json.loads(request.raw_post_data), but I'm wondering if this is a bug or if I am just missing something. Any help would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3d786ca3-a9b6-4a44-8ba3-aead63a135e1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment