From ee3d4f521f0adc58fa41fc28255dc35f24efda4a Mon Sep 17 00:00:00 2001 From: Andreas Hasenkopf Date: Mon, 19 Oct 2020 18:23:41 +0200 Subject: [PATCH] Include tests and examples in source package, but don't install them (#1034) ..., but don't install them. Also applied changes as suggested by `black`. --- MANIFEST.in | 3 +++ django_test_settings.py | 35 ---------------------------- examples/__init__.py | 0 examples/cookbook-plain/__init__.py | 0 examples/cookbook/__init__.py | 0 examples/django_test_settings.py | 30 ++++++++++++++++++++++++ graphene_django/tests/test_fields.py | 6 ++--- pytest.ini | 2 +- setup.py | 2 +- tox.ini | 2 +- 10 files changed, 39 insertions(+), 41 deletions(-) delete mode 100644 django_test_settings.py create mode 100644 examples/__init__.py create mode 100644 examples/cookbook-plain/__init__.py create mode 100644 examples/cookbook/__init__.py create mode 100644 examples/django_test_settings.py diff --git a/MANIFEST.in b/MANIFEST.in index 4677330..045af08 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,6 @@ include README.md LICENSE recursive-include graphene_django/templates * recursive-include graphene_django/static * + +include examples/cookbook/cookbook/ingredients/fixtures/ingredients.json +include examples/cookbook-plain/cookbook/ingredients/fixtures/ingredients.json \ No newline at end of file diff --git a/django_test_settings.py b/django_test_settings.py deleted file mode 100644 index 9279a73..0000000 --- a/django_test_settings.py +++ /dev/null @@ -1,35 +0,0 @@ -import sys -import os - -ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, ROOT_PATH + '/examples/') - -SECRET_KEY = 1 - -INSTALLED_APPS = [ - 'graphene_django', - 'graphene_django.rest_framework', - 'graphene_django.tests', - 'starwars', -] - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': 'django_test.sqlite', - } -} - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], - 'APP_DIRS': True, - }, -] - -GRAPHENE = { - 'SCHEMA': 'graphene_django.tests.schema_view.schema' -} - -ROOT_URLCONF = 'graphene_django.tests.urls' diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/cookbook-plain/__init__.py b/examples/cookbook-plain/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/cookbook/__init__.py b/examples/cookbook/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/django_test_settings.py b/examples/django_test_settings.py new file mode 100644 index 0000000..7b98861 --- /dev/null +++ b/examples/django_test_settings.py @@ -0,0 +1,30 @@ +import sys +import os + +ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0, ROOT_PATH + "/examples/") + +SECRET_KEY = 1 + +INSTALLED_APPS = [ + "graphene_django", + "graphene_django.rest_framework", + "graphene_django.tests", + "examples.starwars", +] + +DATABASES = { + "default": {"ENGINE": "django.db.backends.sqlite3", "NAME": "django_test.sqlite"} +} + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [], + "APP_DIRS": True, + } +] + +GRAPHENE = {"SCHEMA": "graphene_django.tests.schema_view.schema"} + +ROOT_URLCONF = "graphene_django.tests.urls" diff --git a/graphene_django/tests/test_fields.py b/graphene_django/tests/test_fields.py index cd5bd1b..57f913e 100644 --- a/graphene_django/tests/test_fields.py +++ b/graphene_django/tests/test_fields.py @@ -267,7 +267,7 @@ class TestDjangoListField: result = schema.execute(query) assert not result.errors - assert result.data == {"reporters": [{"firstName": "Tara"},]} + assert result.data == {"reporters": [{"firstName": "Tara"}]} def test_resolve_list(self): """Resolving a plain list should work (and not call get_queryset)""" @@ -314,7 +314,7 @@ class TestDjangoListField: result = schema.execute(query) assert not result.errors - assert result.data == {"reporters": [{"firstName": "Debra"},]} + assert result.data == {"reporters": [{"firstName": "Debra"}]} def test_get_queryset_foreign_key(self): class Article(DjangoObjectType): @@ -371,7 +371,7 @@ class TestDjangoListField: assert not result.errors assert result.data == { "reporters": [ - {"firstName": "Tara", "articles": [{"headline": "Amazing news"},],}, + {"firstName": "Tara", "articles": [{"headline": "Amazing news"}]}, {"firstName": "Debra", "articles": []}, ] } diff --git a/pytest.ini b/pytest.ini index 4e47ff4..94360bd 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -DJANGO_SETTINGS_MODULE = django_test_settings +DJANGO_SETTINGS_MODULE = examples.django_test_settings diff --git a/setup.py b/setup.py index 8a070a9..e33cfca 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ setup( "Framework :: Django :: 3.0", ], keywords="api graphql protocol rest relay graphene", - packages=find_packages(exclude=["tests"]), + packages=find_packages(exclude=["tests", "examples", "examples.*"]), install_requires=[ "six>=1.10.0", "graphene>=2.1.7,<3", diff --git a/tox.ini b/tox.ini index 9086a55..bd2f727 100644 --- a/tox.ini +++ b/tox.ini @@ -25,7 +25,7 @@ DJANGO = passenv = * usedevelop = True setenv = - DJANGO_SETTINGS_MODULE=django_test_settings + DJANGO_SETTINGS_MODULE=examples.django_test_settings deps = -e.[test] psycopg2-binary