File tree Expand file tree Collapse file tree 2 files changed +48
-43
lines changed Expand file tree Collapse file tree 2 files changed +48
-43
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def _node_tree_recursive(
19
19
results .append (" " * indent + f"{ type (obj ).__name__ } " )
20
20
21
21
try :
22
- keys = obj .keys
22
+ keys = sorted ( obj .keys )
23
23
except AttributeError :
24
24
# If the object has no keys attribute, print its repr and return.
25
25
results .append (" " * (indent + 1 ) + repr (obj ))
@@ -70,6 +70,9 @@ def node_tree(
70
70
71
71
Useful to debug deep DocumentNode instances created by gql or dsl_gql.
72
72
73
+ NOTE: from gql version 3.6.0b4 the elements of each node are sorted to ignore
74
+ small changes in graphql-core
75
+
73
76
WARNING: the output of this method is not guaranteed and may change without notice.
74
77
"""
75
78
Original file line number Diff line number Diff line change @@ -1030,11 +1030,10 @@ def test_node_tree_with_loc(ds):
1030
1030
1031
1031
node_tree_result = """
1032
1032
DocumentNode
1033
- loc:
1034
- Location
1035
- <Location 0:43>
1036
1033
definitions:
1037
1034
OperationDefinitionNode
1035
+ directives:
1036
+ empty tuple
1038
1037
loc:
1039
1038
Location
1040
1039
<Location 0:43>
@@ -1045,33 +1044,31 @@ def test_node_tree_with_loc(ds):
1045
1044
<Location 6:17>
1046
1045
value:
1047
1046
'GetHeroName'
1048
- directives:
1049
- empty tuple
1050
- variable_definitions:
1051
- empty tuple
1047
+ operation:
1048
+ <OperationType.QUERY: 'query'>
1052
1049
selection_set:
1053
1050
SelectionSetNode
1054
1051
loc:
1055
1052
Location
1056
1053
<Location 18:43>
1057
1054
selections:
1058
1055
FieldNode
1056
+ alias:
1057
+ None
1058
+ arguments:
1059
+ empty tuple
1060
+ directives:
1061
+ empty tuple
1059
1062
loc:
1060
1063
Location
1061
1064
<Location 22:41>
1062
- directives:
1063
- empty tuple
1064
- alias:
1065
- None
1066
1065
name:
1067
1066
NameNode
1068
1067
loc:
1069
1068
Location
1070
1069
<Location 22:26>
1071
1070
value:
1072
1071
'hero'
1073
- arguments:
1074
- empty tuple
1075
1072
nullability_assertion:
1076
1073
None
1077
1074
selection_set:
@@ -1081,37 +1078,39 @@ def test_node_tree_with_loc(ds):
1081
1078
<Location 27:41>
1082
1079
selections:
1083
1080
FieldNode
1081
+ alias:
1082
+ None
1083
+ arguments:
1084
+ empty tuple
1085
+ directives:
1086
+ empty tuple
1084
1087
loc:
1085
1088
Location
1086
1089
<Location 33:37>
1087
- directives:
1088
- empty tuple
1089
- alias:
1090
- None
1091
1090
name:
1092
1091
NameNode
1093
1092
loc:
1094
1093
Location
1095
1094
<Location 33:37>
1096
1095
value:
1097
1096
'name'
1098
- arguments:
1099
- empty tuple
1100
1097
nullability_assertion:
1101
1098
None
1102
1099
selection_set:
1103
1100
None
1104
- operation:
1105
- <OperationType.QUERY: 'query'>
1101
+ variable_definitions:
1102
+ empty tuple
1103
+ loc:
1104
+ Location
1105
+ <Location 0:43>
1106
1106
""" .strip ()
1107
1107
1108
1108
node_tree_result_stable = """
1109
1109
DocumentNode
1110
- loc:
1111
- Location
1112
- <Location 0:43>
1113
1110
definitions:
1114
1111
OperationDefinitionNode
1112
+ directives:
1113
+ empty tuple
1115
1114
loc:
1116
1115
Location
1117
1116
<Location 0:43>
@@ -1122,62 +1121,65 @@ def test_node_tree_with_loc(ds):
1122
1121
<Location 6:17>
1123
1122
value:
1124
1123
'GetHeroName'
1125
- directives:
1126
- empty tuple
1127
- variable_definitions:
1128
- empty tuple
1124
+ operation:
1125
+ <OperationType.QUERY: 'query'>
1129
1126
selection_set:
1130
1127
SelectionSetNode
1131
1128
loc:
1132
1129
Location
1133
1130
<Location 18:43>
1134
1131
selections:
1135
1132
FieldNode
1133
+ alias:
1134
+ None
1135
+ arguments:
1136
+ empty tuple
1137
+ directives:
1138
+ empty tuple
1136
1139
loc:
1137
1140
Location
1138
1141
<Location 22:41>
1139
- directives:
1140
- empty tuple
1141
- alias:
1142
- None
1143
1142
name:
1144
1143
NameNode
1145
1144
loc:
1146
1145
Location
1147
1146
<Location 22:26>
1148
1147
value:
1149
1148
'hero'
1150
- arguments:
1151
- empty tuple
1152
1149
selection_set:
1153
1150
SelectionSetNode
1154
1151
loc:
1155
1152
Location
1156
1153
<Location 27:41>
1157
1154
selections:
1158
1155
FieldNode
1156
+ alias:
1157
+ None
1158
+ arguments:
1159
+ empty tuple
1160
+ directives:
1161
+ empty tuple
1159
1162
loc:
1160
1163
Location
1161
1164
<Location 33:37>
1162
- directives:
1163
- empty tuple
1164
- alias:
1165
- None
1166
1165
name:
1167
1166
NameNode
1168
1167
loc:
1169
1168
Location
1170
1169
<Location 33:37>
1171
1170
value:
1172
1171
'name'
1173
- arguments:
1174
- empty tuple
1175
1172
selection_set:
1176
1173
None
1177
- operation:
1178
- <OperationType.QUERY: 'query'>
1174
+ variable_definitions:
1175
+ empty tuple
1176
+ loc:
1177
+ Location
1178
+ <Location 0:43>
1179
1179
""" .strip ()
1180
1180
1181
+ print (node_tree (document , ignore_loc = False ))
1182
+
1181
1183
try :
1182
1184
assert node_tree (document , ignore_loc = False ) == node_tree_result
1183
1185
except AssertionError :
You can’t perform that action at this time.
0 commit comments