Skip to content

Commit 381ef4b

Browse files
committed
Move kitchen_sink files into fixtures package
Replicates graphql/graphql-js@59d9f17
1 parent e0eb6fb commit 381ef4b

File tree

10 files changed

+45
-36
lines changed

10 files changed

+45
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
1313
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
1414

1515
The current version 1.0.1 of GraphQL-core-next is up-to-date with GraphQL.js version
16-
14.0.2. All parts of the API are covered by an extensive test suite of currently 1682
16+
14.0.2. All parts of the API are covered by an extensive test suite of currently 1683
1717
unit tests.
1818

1919

tests/fixtures/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Fixtures for graphql tests"""
2+
3+
from os.path import dirname, join
4+
5+
from pytest import fixture
6+
7+
__all__ = ["kitchen_sink_query", "kitchen_sink_sdl"]
8+
9+
10+
def read_graphql(name):
11+
path = join(dirname(__file__), name + ".graphql")
12+
return open(path, encoding="utf-8").read()
13+
14+
15+
@fixture(scope="module")
16+
def kitchen_sink_query():
17+
return read_graphql("kitchen_sink")
18+
19+
20+
@fixture(scope="module")
21+
def kitchen_sink_sdl():
22+
return read_graphql("schema_kitchen_sink")

tests/language/__init__.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1 @@
11
"""Tests for graphql.language"""
2-
3-
from os.path import dirname, join
4-
5-
from pytest import fixture
6-
7-
8-
def read_graphql(name):
9-
path = join(dirname(__file__), name + ".graphql")
10-
return open(path, encoding="utf-8").read()
11-
12-
13-
@fixture(scope="module")
14-
def kitchen_sink():
15-
return read_graphql("kitchen_sink")
16-
17-
18-
@fixture(scope="module")
19-
def schema_kitchen_sink():
20-
return read_graphql("schema_kitchen_sink")

tests/language/test_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
)
3131

3232
# noinspection PyUnresolvedReferences
33-
from . import kitchen_sink # noqa: F401
33+
from ..fixtures import kitchen_sink_query # noqa: F401
3434

3535

3636
def assert_syntax_error(text, message, location):
@@ -138,8 +138,8 @@ def parses_multi_byte_characters():
138138
assert value.value == "Has a \u0A0A multi-byte character."
139139

140140
# noinspection PyShadowingNames
141-
def parses_kitchen_sink(kitchen_sink): # noqa: F811
142-
parse(kitchen_sink)
141+
def parses_kitchen_sink(kitchen_sink_query): # noqa: F811
142+
parse(kitchen_sink_query)
143143

144144
def allows_non_keywords_anywhere_a_name_is_allowed():
145145
non_keywords = (

tests/language/test_printer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
from graphql.language import FieldNode, NameNode, parse, print_ast
77

88
# noinspection PyUnresolvedReferences
9-
from . import kitchen_sink # noqa: F401
9+
from ..fixtures import kitchen_sink_query # noqa: F401
1010

1111

1212
def describe_printer_query_document():
1313

1414
# noinspection PyShadowingNames
15-
def does_not_alter_ast(kitchen_sink): # noqa: F811
16-
ast = parse(kitchen_sink)
15+
def does_not_alter_ast(kitchen_sink_query): # noqa: F811
16+
ast = parse(kitchen_sink_query)
1717
ast_before = deepcopy(ast)
1818
print_ast(ast)
1919
assert ast == ast_before
@@ -134,8 +134,8 @@ def experimental_correctly_prints_fragment_defined_variables():
134134
assert print_ast(fragment_with_variable) == dedent(source)
135135

136136
# noinspection PyShadowingNames
137-
def prints_kitchen_sink(kitchen_sink): # noqa: F811
138-
ast = parse(kitchen_sink)
137+
def prints_kitchen_sink(kitchen_sink_query): # noqa: F811
138+
ast = parse(kitchen_sink_query)
139139
printed = print_ast(ast)
140140
assert printed == dedent(
141141
r'''

tests/language/test_schema_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
parse,
2929
)
3030

31+
# noinspection PyUnresolvedReferences
32+
from ..fixtures import kitchen_sink_sdl # noqa: F401
33+
3134

3235
def assert_syntax_error(text, message, location):
3336
with raises(GraphQLSyntaxError) as exc_info:
@@ -614,6 +617,9 @@ def directive_with_incorrect_locations():
614617
(2, 27),
615618
)
616619

620+
def parses_kitchen_sink_schema(kitchen_sink_sdl): # noqa: F811
621+
assert parse(kitchen_sink_sdl)
622+
617623
def disallow_legacy_sdl_empty_fields_supports_type_with_empty_fields():
618624
assert_syntax_error(
619625
"type Hello { }", "Syntax Error: Expected Name, found }", (1, 14)

tests/language/test_schema_printer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from graphql.pyutils import dedent
77

88
# noinspection PyUnresolvedReferences
9-
from . import schema_kitchen_sink as kitchen_sink # noqa: F401
9+
from ..fixtures import kitchen_sink_sdl # noqa: F401
1010

1111

1212
def describe_printer_sdl_document():
@@ -23,15 +23,15 @@ def produces_helpful_error_messages():
2323
assert msg == "Not an AST Node: {'random': 'Data'}"
2424

2525
# noinspection PyShadowingNames
26-
def does_not_alter_ast(kitchen_sink): # noqa: F811
27-
ast = parse(kitchen_sink)
26+
def does_not_alter_ast(kitchen_sink_sdl): # noqa: F811
27+
ast = parse(kitchen_sink_sdl)
2828
ast_copy = deepcopy(ast)
2929
print_ast(ast)
3030
assert ast == ast_copy
3131

3232
# noinspection PyShadowingNames
33-
def prints_kitchen_sink(kitchen_sink): # noqa: F811
34-
ast = parse(kitchen_sink)
33+
def prints_kitchen_sink(kitchen_sink_sdl): # noqa: F811
34+
ast = parse(kitchen_sink_sdl)
3535
printed = print_ast(ast)
3636

3737
assert printed == dedent(

tests/language/test_visitor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ..validation.harness import test_schema
2424

2525
# noinspection PyUnresolvedReferences
26-
from . import kitchen_sink # noqa: F401
26+
from ..fixtures import kitchen_sink_query # noqa: F401
2727

2828

2929
def get_node_by_path(ast, path):
@@ -413,8 +413,8 @@ def leave(self, *args):
413413
]
414414

415415
# noinspection PyShadowingNames
416-
def visits_kitchen_sink(kitchen_sink): # noqa: F811
417-
ast = parse(kitchen_sink)
416+
def visits_kitchen_sink(kitchen_sink_query): # noqa: F811
417+
ast = parse(kitchen_sink_query)
418418
visited = []
419419

420420
# noinspection PyMethodMayBeStatic

0 commit comments

Comments
 (0)