From 0311830771bc8a2d99d43b86472063f1f4bee3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Br=C3=A9mond?= Date: Thu, 31 Dec 2020 14:18:16 -0800 Subject: [PATCH 1/2] Fix project setup --- setup.cfg | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index d58878633..52f6bf697 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,5 +45,5 @@ use_parentheses=True line_length=88 [tool:pytest] -DJANGO_SETTINGS_MODULE = django_test_settings +DJANGO_SETTINGS_MODULE = examples.django_test_settings addopts = --random-order diff --git a/setup.py b/setup.py index 4750671cb..3358ab148 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,7 @@ "coveralls", "mock", "pytz", + "psycopg2-binary", "django-filter>=2", "pytest-django>=3.3.2", ] + rest_framework_require From 933c6af14922a368b0172ebcfb634eac2c8a4803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Br=C3=A9mond?= Date: Fri, 1 Jan 2021 23:11:07 -0800 Subject: [PATCH 2/2] Fix test_should_query_postgres_fields --- graphene_django/compat.py | 5 ++++- graphene_django/tests/test_query.py | 4 ++-- setup.py | 1 - 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/graphene_django/compat.py b/graphene_django/compat.py index 8a2b93369..537fd1da3 100644 --- a/graphene_django/compat.py +++ b/graphene_django/compat.py @@ -6,13 +6,16 @@ class MissingType(object): # Postgres fields are only available in Django with psycopg2 installed # and we cannot have psycopg2 on PyPy from django.contrib.postgres.fields import ( + IntegerRangeField, ArrayField, HStoreField, JSONField as PGJSONField, RangeField, ) except ImportError: - ArrayField, HStoreField, PGJSONField, RangeField = (MissingType,) * 4 + IntegerRangeField, ArrayField, HStoreField, PGJSONField, RangeField = ( + MissingType, + ) * 5 try: # JSONField is only available from Django 3.1 diff --git a/graphene_django/tests/test_query.py b/graphene_django/tests/test_query.py index 2ff81a34f..699814d2c 100644 --- a/graphene_django/tests/test_query.py +++ b/graphene_django/tests/test_query.py @@ -11,7 +11,7 @@ import graphene from graphene.relay import Node -from ..compat import JSONField, MissingType +from ..compat import IntegerRangeField, MissingType from ..fields import DjangoConnectionField from ..types import DjangoObjectType from ..utils import DJANGO_FILTER_INSTALLED @@ -114,7 +114,7 @@ def resolve_reporter(self, info): assert result.data == expected -@pytest.mark.skipif(JSONField is MissingType, reason="RangeField should exist") +@pytest.mark.skipif(IntegerRangeField is MissingType, reason="RangeField should exist") def test_should_query_postgres_fields(): from django.contrib.postgres.fields import ( IntegerRangeField, diff --git a/setup.py b/setup.py index 3358ab148..4750671cb 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,6 @@ "coveralls", "mock", "pytz", - "psycopg2-binary", "django-filter>=2", "pytest-django>=3.3.2", ] + rest_framework_require