8000 ✅ Fix usage of mock.call_args.args · graphql-python/graphene-django@5464cf1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5464cf1

Browse files
committed
✅ Fix usage of mock.call_args.args
Not present before python 3.8
1 parent bb72b37 commit 5464cf1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

graphene_django/tests/test_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import sys
23

34
import pytest
45
from django.utils.translation import gettext_lazy
@@ -8,6 +9,10 @@
89
from .models import Film, Reporter
910
from ..utils.testing import graphql_query
1011

12+
def call_args_compat(mock):
13+
if sys.version_info < (3, 8):
14+
setattr(mock.call_args, 'args', mock.call_args[0])
15+
return mock.call_args
1116

1217
def test_get_model_fields_no_duplication():
1318
reporter_fields = get_model_fields(Reporter)
@@ -54,7 +59,7 @@ def runTest(self):
5459
tc._pre_setup()
5560
tc.setUpClass()
5661
tc.query("query { }", operation_name="QueryName")
57-
body = json.loads(post_mock.call_args.args[1])
62+
body = json.loads(call_args_compat(post_mock).args[1])
5863
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
5964
assert (
6065
"operationName",
@@ -66,7 +71,7 @@ def runTest(self):
6671
@patch("graphene_django.utils.testing.Client.post")
6772
def test_graphql_query_case_operation_name(post_mock):
6873
graphql_query("query { }", operation_name="QueryName")
69-
body = json.loads(post_mock.call_args.args[1])
74+
body = json.loads(call_args_compat(post_mock).args[1])
7075
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
7176
assert (
7277
"operationName",

0 commit comments

Comments
 (0)
0