Skip to content

Commit 4b7119d

Browse files
authored
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
1 parent eb7a026 commit 4b7119d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

graphene_django/utils/testing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ def assertResponseNoErrors(self, resp, msg=None):
109109
the call was fine.
110110
:resp HttpResponse: Response
111111
"""
112-
self.assertEqual(resp.status_code, 200)
113112
content = json.loads(resp.content)
114-
self.assertNotIn("errors", list(content.keys()), msg)
113+
self.assertEqual(resp.status_code, 200, msg or content)
114+
self.assertNotIn("errors", list(content.keys()), msg or content)
115115

116116
def assertResponseHasErrors(self, resp, msg=None):
117117
"""
118118
Assert that the call was failing. Take care: Even with errors, GraphQL returns status 200!
119119
:resp HttpResponse: Response
120120
"""
121121
content = json.loads(resp.content)
122-
self.assertIn("errors", list(content.keys()), msg)
122+
self.assertIn("errors", list(content.keys()), msg or content)

0 commit comments

Comments
 (0)