1
1
from typing import cast
2
2
3
- from pytest import fixture , mark , raises
3
+ from pytest import mark , raises
4
4
5
5
from graphql .language import parse
6
6
from graphql .type import (
@@ -784,8 +784,7 @@ def schema_with_enum(name):
784
784
785
785
786
786
def describe_type_system_object_fields_must_have_output_types ():
787
- @fixture
788
- def schema_with_object_field_of_type (field_type ):
787
+ def _schema_with_object_field_of_type (field_type ):
789
788
BadObjectType = GraphQLObjectType (
790
789
"BadObject" , {"badField" : GraphQLField (field_type )}
791
790
)
@@ -796,29 +795,29 @@ def schema_with_object_field_of_type(field_type):
796
795
797
796
@mark .parametrize ("type_" , output_types )
798
797
def accepts_an_output_type_as_an_object_field_type (type_ ):
799
- schema = schema_with_object_field_of_type (type_ )
798
+ schema = _schema_with_object_field_of_type (type_ )
800
799
assert validate_schema (schema ) == []
801
800
802
801
def rejects_an_empty_object_field_type ():
803
802
# invalid schema cannot be built with Python
804
803
with raises (TypeError ) as exc_info :
805
- schema_with_object_field_of_type (None )
804
+ _schema_with_object_field_of_type (None )
806
805
msg = str (exc_info .value )
807
806
assert msg == "Field type must be an output type."
808
807
809
808
@mark .parametrize ("type_" , not_output_types )
810
809
def rejects_a_non_output_type_as_an_object_field_type (type_ ):
811
810
# invalid schema cannot be built with Python
812
811
with raises (TypeError ) as exc_info :
813
- schema_with_object_field_of_type (type_ )
812
+ _schema_with_object_field_of_type (type_ )
814
813
msg = str (exc_info .value )
815
814
assert msg == "Field type must be an output type."
816
815
817
816
@mark .parametrize ("type_" , [int , float , str ])
818
817
def rejects_a_non_type_value_as_an_object_field_type (type_ ):
819
818
# invalid schema cannot be built with Python
820
819
with raises (TypeError ) as exc_info :
821
- schema_with_object_field_of_type (type_ )
820
+ _schema_with_object_field_of_type (type_ )
822
821
msg = str (exc_info .value )
823
822
assert msg == "Field type must be an output type."
824
823
@@ -1064,8 +1063,7 @@ def rejects_object_implementing_extended_interface_due_to_type_mismatch():
1064
1063
1065
1064
1066
1065
def describe_type_system_interface_fields_must_have_output_types ():
1067
- @fixture
1068
- def schema_with_interface_field_of_type (field_type ):
1066
+ def _schema_with_interface_field_of_type (field_type ):
1069
1067
BadInterfaceType = GraphQLInterfaceType (
1070
1068
"BadInterface" , {"badField" : GraphQLField (field_type )}
1071
1069
)
@@ -1081,29 +1079,29 @@ def schema_with_interface_field_of_type(field_type):
1081
1079
1082
1080
@mark .parametrize ("type_" , output_types )
1083
1081
def accepts_an_output_type_as_an_interface_field_type (type_ ):
1084
- schema = schema_with_interface_field_of_type (type_ )
1082
+ schema = _schema_with_interface_field_of_type (type_ )
1085
1083
assert validate_schema (schema ) == []
1086
1084
1087
1085
def rejects_an_empty_interface_field_type ():
1088
1086
# invalid schema cannot be built with Python
1089
1087
with raises (TypeError ) as exc_info :
1090
- schema_with_interface_field_of_type (None )
1088
+ _schema_with_interface_field_of_type (None )
1091
1089
msg = str (exc_info .value )
1092
1090
assert msg == "Field type must be an output type."
1093
1091
1094
1092
@mark .parametrize ("type_" , not_output_types )
1095
1093
def rejects_a_non_output_type_as_an_interface_field_type (type_ ):
1096
1094
# invalid schema cannot be built with Python
1097
1095
with raises (TypeError ) as exc_info :
1098
- schema_with_interface_field_of_type (type_ )
1096
+ _schema_with_interface_field_of_type (type_ )
1099
1097
msg = str (exc_info .value )
1100
1098
assert msg == "Field type must be an output type."
1101
1099
1102
1100
@mark .parametrize ("type_" , [int , float , str ])
1103
1101
def rejects_a_non_type_value_as_an_interface_field_type (type_ ):
1104
1102
# invalid schema cannot be built with Python
1105
1103
with raises (TypeError ) as exc_info :
1106
- schema_with_interface_field_of_type (type_ )
1104
+ _schema_with_interface_field_of_type (type_ )
1107
1105
msg = str (exc_info .value )
1108
1106
assert msg == "Field type must be an output type."
1109
1107
@@ -1151,8 +1149,7 @@ def accepts_an_interface_not_implemented_by_at_least_one_object():
1151
1149
1152
1150
1153
1151
def describe_type_system_field_arguments_must_have_input_types ():
1154
- @fixture
1155
- def schema_with_arg_of_type (arg_type ):
1152
+ def _schema_with_arg_of_type (arg_type ):
1156
1153
BadObjectType = GraphQLObjectType (
1157
1154
"BadObject" ,
1158
1155
{
@@ -1167,29 +1164,29 @@ def schema_with_arg_of_type(arg_type):
1167
1164
1168
1165
@mark .parametrize ("type_" , input_types )
1169
1166
def accepts_an_input_type_as_a_field_arg_type (type_ ):
1170
- schema = schema_with_arg_of_type (type_ )
1167
+ schema = _schema_with_arg_of_type (type_ )
1171
1168
assert validate_schema (schema ) == []
1172
1169
1173
1170
def rejects_an_empty_field_arg_type ():
1174
1171
# invalid schema cannot be built with Python
1175
1172
with raises (TypeError ) as exc_info :
1176
- schema_with_arg_of_type (None )
1173
+ _schema_with_arg_of_type (None )
1177
1174
msg = str (exc_info .value )
1178
1175
assert msg == "Argument type must be a GraphQL input type."
1179
1176
1180
1177
@mark .parametrize ("type_" , not_input_types )
1181
1178
def rejects_a_non_input_type_as_a_field_arg_type (type_ ):
1182
1179
# invalid schema cannot be built with Python
1183
1180
with raises (TypeError ) as exc_info :
1184
- schema_with_arg_of_type (type_ )
1181
+ _schema_with_arg_of_type (type_ )
1185
1182
msg = str (exc_info .value )
1186
1183
assert msg == "Argument type must be a GraphQL input type."
1187
1184
1188
1185
@mark .parametrize ("type_" , [int , float , str ])
1189
1186
def rejects_a_non_type_value_as_a_field_arg_type (type_ ):
1190
1187
# invalid schema cannot be built with Python
1191
1188
with raises (TypeError ) as exc_info :
1192
- schema_with_arg_of_type (type_ )
1189
+ _schema_with_arg_of_type (type_ )
1193
1190
msg = str (exc_info .value )
1194
1191
assert msg == "Argument type must be a GraphQL input type."
1195
1192
@@ -1215,8 +1212,7 @@ def rejects_a_non_input_type_as_a_field_arg_with_locations():
1215
1212
1216
1213
1217
1214
def describe_type_system_input_object_fields_must_have_input_types ():
1218
- @fixture
1219
- def schema_with_input_field_of_type (input_field_type ):
1215
+ def _schema_with_input_field_of_type (input_field_type ):
1220
1216
BadInputObjectType = GraphQLInputObjectType (
1221
1217
"BadInputObject" , {"badField" : GraphQLInputField (input_field_type )}
1222
1218
)
@@ -1234,29 +1230,29 @@ def schema_with_input_field_of_type(input_field_type):
1234
1230
1235
1231
@mark .parametrize ("type_" , input_types )
1236
1232
def accepts_an_input_type_as_an_input_fieldtype (type_ ):
1237
- schema = schema_with_input_field_of_type (type_ )
1233
+ schema = _schema_with_input_field_of_type (type_ )
1238
1234
assert validate_schema (schema ) == []
1239
1235
1240
1236
def rejects_an_empty_input_field_type ():
1241
1237
# invalid schema cannot be built with Python
1242
1238
with raises (TypeError ) as exc_info :
1243
- schema_with_input_field_of_type (None )
1239
+ _schema_with_input_field_of_type (None )
1244
1240
msg = str (exc_info .value )
1245
1241
assert msg == "Input field type must be a GraphQL input type."
1246
1242
1247
1243
@mark .parametrize ("type_" , not_input_types )
1248
1244
def rejects_a_non_input_type_as_an_input_field_type (type_ ):
1249
1245
# invalid schema cannot be built with Python
1250
1246
with raises (TypeError ) as exc_info :
1251
- schema_with_input_field_of_type (type_ )
1247
+ _schema_with_input_field_of_type (type_ )
1252
1248
msg = str (exc_info .value )
1253
1249
assert msg == "Input field type must be a GraphQL input type."
1254
1250
1255
1251
@mark .parametrize ("type_" , [int , float , str ])
1256
1252
def rejects_a_non_type_value_as_an_input_field_type (type_ ):
1257
1253
# invalid schema cannot be built with Python
1258
1254
with raises (TypeError ) as exc_info :
1259
- schema_with_input_field_of_type (type_ )
1255
+ _schema_with_input_field_of_type (type_ )
1260
1256
msg = str (exc_info .value )
1261
1257
assert msg == "Input field type must be a GraphQL input type."
1262
1258
0 commit comments