Skip to content

Commit 7c780a9

Browse files
santiagoaguiaryuekuijaw9ckiendang
authored
Backport Django 4.1 compatibility fixes to v2 (#1413)
* handle deprecation warning for requires_system_checks Removed in django 4.1. * Fix broken UT due to pytest import error (#1368) * import error resolved? * Fix tests * Remove Python 3.6 * django 4.1 requires python>=3.10 * Django 4.1 does support python 3.8 to 3.11 * Add Django 4.1 to tox --------- Co-authored-by: Yuekui <[email protected]> Co-authored-by: Josh Warwick <[email protected]> Co-authored-by: Kien Dang <[email protected]>
1 parent ede3880 commit 7c780a9

File tree

15 files changed

+24
-27
lines changed

15 files changed

+24
-27
lines changed

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
pip install wheel
2121
python setup.py sdist bdist_wheel
2222
- name: Publish a Python distribution to PyPI
23-
uses: pypa/gh-action-pypi-publish@v1.1.0
23+
uses: pypa/gh-action-pypi-publish@release/v1
2424
with:
2525
user: __token__
2626
password: ${{ secrets.pypi_password }}

.github/workflows/tests.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,23 @@ jobs:
88
strategy:
99
max-parallel: 4
1010
matrix:
11-
django: ["2.2", "3.0", "3.1", "3.2", "4.0"]
11+
django: ["2.2", "3.0", "3.1", "3.2", "4.0", "4.1"]
1212
python-version: ["3.8", "3.9"]
1313
include:
14-
- django: "2.2"
15-
python-version: "3.6"
1614
- django: "2.2"
1715
python-version: "3.7"
18-
- django: "3.0"
19-
python-version: "3.6"
2016
- django: "3.0"
2117
python-version: "3.7"
22-
- django: "3.1"
23-
python-version: "3.6"
2418
- django: "3.1"
2519
python-version: "3.7"
26-
- django: "3.2"
27-
python-version: "3.6"
2820
- django: "3.2"
2921
python-version: "3.7"
3022
- django: "3.2"
3123
python-version: "3.10"
3224
- django: "4.0"
3325
python-version: "3.10"
26+
- django: "4.1"
27+
python-version: "3.10"
3428
steps:
3529
- uses: actions/checkout@v3
3630
- name: Set up Python ${{ matrix.python-version }}

graphene_django/filter/tests/test_array_field_exact_filter.py

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def test_array_field_exact_empty_list(Query):
8181
]
8282

8383

84+
@pytest.mark.skipif(ArrayField is MissingType, reason="ArrayField should exist")
8485
def test_array_field_filter_schema_type(Query):
8586
"""
8687
Check that the type in the filter is an array field like on the object type.

graphene_django/forms/tests/test_converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django import forms
2-
from py.test import raises
2+
from pytest import raises
33

44
from graphene import (
55
Boolean,

graphene_django/forms/tests/test_mutation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from django import forms
33
from django.core.exceptions import ValidationError
4-
from py.test import raises
4+
from pytest import raises
55

66
from graphene import Field, ObjectType, Schema, String
77
from graphene_django import DjangoObjectType

graphene_django/management/commands/graphql_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def add_arguments(self, parser):
4848
class Command(CommandArguments):
4949
help = "Dump Graphene schema as a JSON or GraphQL file"
5050
can_import_settings = True
51-
requires_system_checks = False
51+
requires_system_checks = []
5252

5353
def save_json_file(self, out, schema_dict, indent):
5454
with open(out, "w") as outfile:

graphene_django/rest_framework/tests/test_field_converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import graphene
44
from django.db import models
55
from graphene import InputObjectType
6-
from py.test import raises
6+
from pytest import raises
77
from rest_framework import serializers
88

99
from ..serializer_converter import convert_serializer_field

graphene_django/rest_framework/tests/test_mutation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datetime
22

3-
from py.test import raises
3+
from pytest import raises
44
from rest_framework import serializers
55

66
from graphene import Field, ResolveInfo, NonNull, String

graphene_django/tests/issues/test_520.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from graphene import Field, ResolveInfo
1010
from graphene.types.inputobjecttype import InputObjectType
11-
from py.test import raises
12-
from py.test import mark
11+
from pytest import raises
12+
from pytest import mark
1313
from rest_framework import serializers
1414

1515
from ...types import DjangoObjectType

graphene_django/tests/test_command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Query(ObjectType):
4646
open_mock.assert_called_once()
4747

4848
handle = open_mock()
49-
assert handle.write.called_once()
49+
handle.write.assert_called_once()
5050

5151
schema_output = handle.write.call_args[0][0]
5252
assert schema_output == dedent(

graphene_django/tests/test_converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from django.db import models
55
from django.utils.translation import gettext_lazy as _
6-
from py.test import raises
6+
from pytest import raises
77

88
import graphene
99
from graphene import NonNull

graphene_django/tests/test_forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.core.exceptions import ValidationError
2-
from py.test import raises
2+
from pytest import raises
33

44
from ..forms import GlobalIDFormField, GlobalIDMultipleChoiceField
55

graphene_django/tests/test_query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.db.models import Q
77
from django.utils.functional import SimpleLazyObject
88
from graphql_relay import to_global_id
9-
from py.test import raises
9+
from pytest import raises
1010

1111
import graphene
1212
from graphene.relay import Node

graphene_django/tests/test_schema.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from py.test import raises
1+
from pytest import raises
22

33
from ..registry import Registry
44
from ..types import DjangoObjectType

tox.ini

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
[tox]
22
envlist =
3-
py{36,37,38,39}-django22,
4-
py{36,37,38,39}-django{30,31},
5-
py{36,37,38,39,310}-django32,
6-
py{38,39,310}-django{40,master},
3+
py{37,38,39}-django22,
4+
py{37,38,39}-django{30,31},
5+
py{37,38,39,310}-django32,
6+
py{38,39,310}-django{40,41,master},
77
black,flake8
88

99
[gh-actions]
1010
python =
11-
3.6: py36
1211
3.7: py37
1312
3.8: py38
1413
3.9: py39
@@ -21,13 +20,15 @@ DJANGO =
2120
3.1: django31
2221
3.2: django32
2322
4.0: django40
23+
4.1: django41
2424
master: djangomaster
2525

2626
[testenv]
2727
passenv = *
2828
usedevelop = True
2929
setenv =
3030
DJANGO_SETTINGS_MODULE=examples.django_test_settings
31+
PYTHONPATH=.
3132
deps =
3233
-e.[test]
3334
psycopg2-binary
@@ -36,6 +37,7 @@ deps =
3637
django31: Django>=3.1,<3.2
3738
django32: Django>=3.2,<4.0
3839
django40: Django>=4.0,<4.1
40+
django41: Django>=4.1.3,<4.2
3941
djangomaster: https://github.com/django/django/archive/master.zip
4042
commands = {posargs:py.test --cov=graphene_django graphene_django examples}
4143

0 commit comments

Comments
 (0)