Add a default msg to show the response content. (#1064)

* Add a default msg to show the response content.

This seems like an issue with using assertResponseNoErrors and assertResponseHasErrors 

Which doesn't include any errors specific to the response and currently just shows.

```python
    self.assertNotIn("errors", list(content.keys()))
AssertionError: 'errors' unexpectedly found in ['errors', 'data']
```

* Update testing.py
This commit is contained in:
Tonye Jack 2020-11-27 18:52:42 -05:00 committed by GitHub
parent eb7a0265d8
commit 4b7119d691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,9 +109,9 @@ class GraphQLTestCase(TestCase):
the call was fine. the call was fine.
:resp HttpResponse: Response :resp HttpResponse: Response
""" """
self.assertEqual(resp.status_code, 200)
content = json.loads(resp.content) content = json.loads(resp.content)
self.assertNotIn("errors", list(content.keys()), msg) self.assertEqual(resp.status_code, 200, msg or content)
self.assertNotIn("errors", list(content.keys()), msg or content)
def assertResponseHasErrors(self, resp, msg=None): def assertResponseHasErrors(self, resp, msg=None):
""" """
@ -119,4 +119,4 @@ class GraphQLTestCase(TestCase):
:resp HttpResponse: Response :resp HttpResponse: Response
""" """
content = json.loads(resp.content) content = json.loads(resp.content)
self.assertIn("errors", list(content.keys()), msg) self.assertIn("errors", list(content.keys()), msg or content)