From 26960359a2d194e6f5f5923c8b85c49b383a8e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Wed, 26 Aug 2020 17:58:48 +0300 Subject: [PATCH] Add msg params to testing class (#1032) --- graphene_django/utils/testing.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graphene_django/utils/testing.py b/graphene_django/utils/testing.py index 6b2d3e8..b1aa29b 100644 --- a/graphene_django/utils/testing.py +++ b/graphene_django/utils/testing.py @@ -103,7 +103,7 @@ class GraphQLTestCase(TestCase): graphql_url=self.GRAPHQL_URL, ) - def assertResponseNoErrors(self, resp): + def assertResponseNoErrors(self, resp, msg=None): """ Assert that the call went through correctly. 200 means the syntax is ok, if there are no `errors`, the call was fine. @@ -111,12 +111,12 @@ class GraphQLTestCase(TestCase): """ self.assertEqual(resp.status_code, 200) content = json.loads(resp.content) - self.assertNotIn("errors", list(content.keys())) + self.assertNotIn("errors", list(content.keys()), msg) - def assertResponseHasErrors(self, resp): + def assertResponseHasErrors(self, resp, msg=None): """ Assert that the call was failing. Take care: Even with errors, GraphQL returns status 200! :resp HttpResponse: Response """ content = json.loads(resp.content) - self.assertIn("errors", list(content.keys())) + self.assertIn("errors", list(content.keys()), msg)