From 7ac0e82176d519abc3d84b8b4f55ebb1bbbee548 Mon Sep 17 00:00:00 2001 From: Tom Nightingale Date: Wed, 26 Feb 2020 17:04:58 -0800 Subject: [PATCH 1/2] Use the Django Client test utility instance that Django provides with its TestCase class. This allows GraphQL tests to make use of the stateful client methods like login() --- graphene_django/utils/testing.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/graphene_django/utils/testing.py b/graphene_django/utils/testing.py index 8a9b99483..182ef1b37 100644 --- a/graphene_django/utils/testing.py +++ b/graphene_django/utils/testing.py @@ -1,6 +1,6 @@ import json -from django.test import TestCase, Client +from django.test import Client, TestCase class GraphQLTestCase(TestCase): @@ -22,8 +22,6 @@ def setUpClass(cls): "Variable GRAPHQL_SCHEMA not defined in GraphQLTestCase." ) - cls._client = Client() - def query(self, query, op_name=None, input_data=None, variables=None, headers=None): """ Args: @@ -54,14 +52,14 @@ def query(self, query, op_name=None, input_data=None, variables=None, headers=No else: body["variables"] = {"input": input_data} if headers: - resp = self._client.post( + resp = self.client.post( self.GRAPHQL_URL, json.dumps(body), content_type="application/json", **headers ) else: - resp = self._client.post( + resp = self.client.post( self.GRAPHQL_URL, json.dumps(body), content_type="application/json" ) return resp From d96c032add1c62f88597e5ff678af885eb160b44 Mon Sep 17 00:00:00 2001 From: Tom Nightingale Date: Tue, 19 May 2020 16:43:04 -0700 Subject: [PATCH 2/2] Remove unused import --- graphene_django/utils/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene_django/utils/testing.py b/graphene_django/utils/testing.py index 182ef1b37..ac89ebffb 100644 --- a/graphene_django/utils/testing.py +++ b/graphene_django/utils/testing.py @@ -1,6 +1,6 @@ import json -from django.test import Client, TestCase +from django.test import TestCase class GraphQLTestCase(TestCase):