Skip to content

Commit 4315568

Browse files
committed
test_type_info: remove dependency on harness schema for validation tests
Replicates graphql/graphql-js@0b7625f
1 parent d5e747d commit 4315568

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

tests/utilities/test_type_info.py

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,52 @@
1010
visit,
1111
Visitor,
1212
)
13-
from graphql.type import get_named_type, is_composite_type
13+
from graphql.type import GraphQLSchema, get_named_type, is_composite_type
1414
from graphql.utilities import TypeInfo, TypeInfoVisitor, build_schema
1515

16-
from ..validation.harness import test_schema
17-
1816
from ..fixtures import kitchen_sink_query # noqa: F401
1917

2018

19+
test_schema = build_schema(
20+
"""
21+
interface Pet {
22+
name: String
23+
}
24+
25+
type Dog implements Pet {
26+
name: String
27+
}
28+
29+
type Cat implements Pet {
30+
name: String
31+
}
32+
33+
type Human {
34+
name: String
35+
pets: [Pet]
36+
}
37+
38+
type Alien {
39+
name(surname: Boolean): String
40+
}
41+
42+
type QueryRoot {
43+
human(id: ID): Human
44+
alien: Alien
45+
}
46+
47+
schema {
48+
query: QueryRoot
49+
}
50+
"""
51+
)
52+
53+
2154
def describe_type_info():
55+
schema = GraphQLSchema()
56+
2257
def allow_all_methods_to_be_called_before_entering_any_mode():
23-
type_info = TypeInfo(test_schema)
58+
type_info = TypeInfo(schema)
2459

2560
assert type_info.get_type() is None
2661
assert type_info.get_parent_type() is None
@@ -306,9 +341,16 @@ def leave(*args):
306341
def supports_traversal_of_input_values():
307342
visited = []
308343

309-
complex_input_type = test_schema.get_type("ComplexInput")
344+
schema = build_schema(
345+
"""
346+
input ComplexInput {
347+
stringListField: [String]
348+
}
349+
"""
350+
)
351+
complex_input_type = schema.get_type("ComplexInput")
310352
assert complex_input_type is not None
311-
type_info = TypeInfo(test_schema, complex_input_type)
353+
type_info = TypeInfo(schema, complex_input_type)
312354

313355
ast = parse_value('{ stringListField: ["foo"] }')
314356

0 commit comments

Comments
 (0)