How to use Django’s assertJSONEqual to verify response of view returning JsonResponse
It looks like you’re working with Python 3 so you’ll need to turn response.content into a UTF-8 encoded string before passing it to self.assertJSONEqual: class AddItemToCollectionTest(TestCase): def test_success_when_not_added_before(self): response = self.client.post(‘/add-item-to-collection’) self.assertEqual(response.status_code, 200) self.assertJSONEqual( str(response.content, encoding=’utf8′), {‘status’: ‘success’} ) If you want to simultaneously support both Python 2.7 and Python 3, use the six compatibility … Read more