mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-15 06:08:59 +03:00
Fix backward compability on GraphQLTestCase._client setter (#1093)
This commit is contained in:
parent
aff56b882b
commit
e24675e5b7
|
@ -99,6 +99,10 @@ class GraphQLTestCase(TestCase):
|
|||
)
|
||||
|
||||
@property
|
||||
def _client(self):
|
||||
pass
|
||||
|
||||
@_client.getter
|
||||
def _client(self):
|
||||
warnings.warn(
|
||||
"Using `_client` is deprecated in favour of `client`.",
|
||||
|
@ -107,6 +111,15 @@ class GraphQLTestCase(TestCase):
|
|||
)
|
||||
return self.client
|
||||
|
||||
@_client.setter
|
||||
def _client(self, client):
|
||||
warnings.warn(
|
||||
"Using `_client` is deprecated in favour of `client`.",
|
||||
PendingDeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
self.client = client
|
||||
|
||||
def assertResponseNoErrors(self, resp, msg=None):
|
||||
"""
|
||||
Assert that the call went through correctly. 200 means the syntax is ok, if there are no `errors`,
|
||||
|
|
|
@ -2,12 +2,13 @@ import pytest
|
|||
|
||||
from .. import GraphQLTestCase
|
||||
from ...tests.test_types import with_local_registry
|
||||
from django.test import Client
|
||||
|
||||
|
||||
@with_local_registry
|
||||
def test_graphql_test_case_deprecated_client():
|
||||
def test_graphql_test_case_deprecated_client_getter():
|
||||
"""
|
||||
Test that `GraphQLTestCase._client`'s should raise pending deprecation warning.
|
||||
`GraphQLTestCase._client`' getter should raise pending deprecation warning.
|
||||
"""
|
||||
|
||||
class TestClass(GraphQLTestCase):
|
||||
|
@ -22,3 +23,23 @@ def test_graphql_test_case_deprecated_client():
|
|||
|
||||
with pytest.warns(PendingDeprecationWarning):
|
||||
tc._client
|
||||
|
||||
|
||||
@with_local_registry
|
||||
def test_graphql_test_case_deprecated_client_setter():
|
||||
"""
|
||||
`GraphQLTestCase._client`' setter should raise pending deprecation warning.
|
||||
"""
|
||||
|
||||
class TestClass(GraphQLTestCase):
|
||||
GRAPHQL_SCHEMA = True
|
||||
|
||||
def runTest(self):
|
||||
pass
|
||||
|
||||
tc = TestClass()
|
||||
tc._pre_setup()
|
||||
tc.setUpClass()
|
||||
|
||||
with pytest.warns(PendingDeprecationWarning):
|
||||
tc._client = Client()
|
||||
|
|
Loading…
Reference in New Issue
Block a user