Skip to content

Commit 47a1651

Browse files
committed
test_printer: do more checks on kitchen sink tests
Replicates graphql/graphql-js@98feb57
1 parent 74b16c6 commit 47a1651

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

tests/language/test_printer.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99

1010

1111
def describe_printer_query_document():
12-
13-
# noinspection PyShadowingNames
14-
def does_not_alter_ast(kitchen_sink_query): # noqa: F811
15-
ast = parse(kitchen_sink_query)
16-
ast_before = deepcopy(ast)
17-
print_ast(ast)
18-
assert ast == ast_before
19-
2012
def prints_minimal_ast():
2113
ast = FieldNode(name=NameNode(value="foo"))
2214
assert print_ast(ast) == "foo"
@@ -136,10 +128,15 @@ def legacy_correctly_prints_fragment_defined_variables():
136128
fragment_with_variable = parse(source, allow_legacy_fragment_variables=True)
137129
assert print_ast(fragment_with_variable) == dedent(source)
138130

139-
# noinspection PyShadowingNames
140-
def prints_kitchen_sink(kitchen_sink_query): # noqa: F811
141-
ast = parse(kitchen_sink_query)
131+
def prints_kitchen_sink_without_altering_ast(kitchen_sink_query): # noqa: F811
132+
ast = parse(kitchen_sink_query, no_location=True)
133+
134+
ast_before_print_call = deepcopy(ast)
142135
printed = print_ast(ast)
136+
printed_ast = parse(printed, no_location=True)
137+
assert printed_ast == ast
138+
assert deepcopy(ast) == ast_before_print_call
139+
143140
assert printed == dedent(
144141
r'''
145142
query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {

tests/language/test_schema_printer.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ def produces_helpful_error_messages():
2222
assert msg == "Not an AST Node: {'random': 'Data'}."
2323

2424
# noinspection PyShadowingNames
25-
def does_not_alter_ast(kitchen_sink_sdl): # noqa: F811
26-
ast = parse(kitchen_sink_sdl)
27-
ast_copy = deepcopy(ast)
28-
print_ast(ast)
29-
assert ast == ast_copy
25+
def prints_kitchen_sink_without_altering_ast(kitchen_sink_sdl): # noqa: F811
26+
ast = parse(kitchen_sink_sdl, no_location=True)
3027

31-
# noinspection PyShadowingNames
32-
def prints_kitchen_sink(kitchen_sink_sdl): # noqa: F811
33-
ast = parse(kitchen_sink_sdl)
28+
ast_before_print_call = deepcopy(ast)
3429
printed = print_ast(ast)
30+
printed_ast = parse(printed, no_location=True)
31+
32+
assert printed_ast == ast
33+
assert deepcopy(ast) == ast_before_print_call
3534

3635
assert printed == dedent(
3736
'''

0 commit comments

Comments
 (0)