1
- from functools import partial
1
+ from operator import attrgetter
2
2
from typing import Any , List , Union
3
3
4
4
from pytest import mark , raises # type: ignore
@@ -108,9 +108,8 @@ def with_modifiers(
108
108
type ("StringType" , (str ,), {"name" : "StringType" }),
109
109
]
110
110
111
- parametrize_type = partial (
112
- mark .parametrize ("type_" , ids = lambda type_ : type_ .__class__ .__name__ )
113
- )
111
+
112
+ get_name = attrgetter ("__class__.__name__" )
114
113
115
114
116
115
def schema_with_field_type (type_ ):
@@ -1025,7 +1024,7 @@ def _schema_with_object_field_of_type(field_type: GraphQLOutputType):
1025
1024
types = [SomeObjectType ],
1026
1025
)
1027
1026
1028
- @parametrize_type ( output_types )
1027
+ @mark . parametrize ( "type_" , output_types , ids = get_name )
1029
1028
def accepts_an_output_type_as_an_object_field_type (type_ ):
1030
1029
schema = _schema_with_object_field_of_type (type_ )
1031
1030
assert validate_schema (schema ) == []
@@ -1040,7 +1039,7 @@ def rejects_an_empty_object_field_type():
1040
1039
}
1041
1040
]
1042
1041
1043
- @parametrize_type ( not_output_types )
1042
+ @mark . parametrize ( "type_" , not_output_types , ids = get_name )
1044
1043
def rejects_a_non_output_type_as_an_object_field_type (type_ ):
1045
1044
schema = _schema_with_object_field_of_type (type_ )
1046
1045
assert validate_schema (schema ) == [
@@ -1050,7 +1049,7 @@ def rejects_a_non_output_type_as_an_object_field_type(type_):
1050
1049
}
1051
1050
]
1052
1051
1053
- @parametrize_type ( not_graphql_types )
1052
+ @mark . parametrize ( "type_" , not_graphql_types , ids = get_name )
1054
1053
def rejects_a_non_type_value_as_an_object_field_type (type_ ):
1055
1054
schema = _schema_with_object_field_of_type (type_ )
1056
1055
assert validate_schema (schema ) == [
@@ -1345,7 +1344,7 @@ def _schema_with_interface_field_of_type(field_type: GraphQLOutputType):
1345
1344
types = [bad_implementing_type , SomeObjectType ],
1346
1345
)
1347
1346
1348
- @parametrize_type ( output_types )
1347
+ @mark . parametrize ( "type_" , output_types , ids = get_name )
1349
1348
def accepts_an_output_type_as_an_interface_field_type (type_ ):
1350
1349
schema = _schema_with_interface_field_of_type (type_ )
1351
1350
assert validate_schema (schema ) == []
@@ -1364,7 +1363,7 @@ def rejects_an_empty_interface_field_type():
1364
1363
},
1365
1364
]
1366
1365
1367
- @parametrize_type ( not_output_types )
1366
+ @mark . parametrize ( "type_" , not_output_types , ids = get_name )
1368
1367
def rejects_a_non_output_type_as_an_interface_field_type (type_ ):
1369
1368
schema = _schema_with_interface_field_of_type (type_ )
1370
1369
assert validate_schema (schema ) == [
@@ -1378,7 +1377,7 @@ def rejects_a_non_output_type_as_an_interface_field_type(type_):
1378
1377
},
1379
1378
]
1380
1379
1381
- @parametrize_type ( not_graphql_types )
1380
+ @mark . parametrize ( "type_" , not_graphql_types , ids = get_name )
1382
1381
def rejects_a_non_type_value_as_an_interface_field_type (type_ ):
1383
1382
schema = _schema_with_interface_field_of_type (type_ )
1384
1383
assert validate_schema (schema ) == [
@@ -1498,7 +1497,7 @@ def _schema_with_arg_of_type(arg_type: GraphQLInputType):
1498
1497
],
1499
1498
)
1500
1499
1501
- @parametrize_type ( input_types )
1500
+ @mark . parametrize ( "type_" , input_types , ids = get_name )
1502
1501
def accepts_an_input_type_as_a_field_arg_type (type_ ):
1503
1502
schema = _schema_with_arg_of_type (type_ )
1504
1503
assert validate_schema (schema ) == []
@@ -1517,7 +1516,7 @@ def rejects_an_empty_field_arg_type():
1517
1516
},
1518
1517
]
1519
1518
1520
- @parametrize_type ( not_input_types )
1519
+ @mark . parametrize ( "type_" , not_input_types , ids = get_name )
1521
1520
def rejects_a_non_input_type_as_a_field_arg_type (type_ ):
1522
1521
schema = _schema_with_arg_of_type (type_ )
1523
1522
assert validate_schema (schema ) == [
@@ -1531,7 +1530,7 @@ def rejects_a_non_input_type_as_a_field_arg_type(type_):
1531
1530
},
1532
1531
]
1533
1532
1534
- @parametrize_type ( not_graphql_types )
1533
+ @mark . parametrize ( "type_" , not_graphql_types , ids = get_name )
1535
1534
def rejects_a_non_type_value_as_a_field_arg_type (type_ ):
1536
1535
schema = _schema_with_arg_of_type (type_ )
1537
1536
assert validate_schema (schema ) == [
@@ -1616,8 +1615,8 @@ def _schema_with_input_field_of_type(input_field_type: GraphQLInputType):
1616
1615
)
1617
1616
)
1618
1617
1619
- @parametrize_type ( input_types )
1620
- def accepts_an_input_type_as_an_input_fieldtype (type_ ):
1618
+ @mark . parametrize ( "type_" , input_types , ids = get_name )
1619
+ def accepts_an_input_type_as_an_input_field_type (type_ ):
1621
1620
schema = _schema_with_input_field_of_type (type_ )
1622
1621
assert validate_schema (schema ) == []
1623
1622
@@ -1631,7 +1630,7 @@ def rejects_an_empty_input_field_type():
1631
1630
}
1632
1631
]
1633
1632
1634
- @parametrize_type ( not_input_types )
1633
+ @mark . parametrize ( "type_" , not_input_types , ids = get_name )
1635
1634
def rejects_a_non_input_type_as_an_input_field_type (type_ ):
1636
1635
schema = _schema_with_input_field_of_type (type_ )
1637
1636
assert validate_schema (schema ) == [
@@ -1641,7 +1640,7 @@ def rejects_a_non_input_type_as_an_input_field_type(type_):
1641
1640
}
1642
1641
]
1643
1642
1644
- @parametrize_type ( not_graphql_types )
1643
+ @mark . parametrize ( "type_" , not_graphql_types , ids = get_name )
1645
1644
def rejects_a_non_type_value_as_an_input_field_type (type_ ):
1646
1645
schema = _schema_with_input_field_of_type (type_ )
1647
1646
assert validate_schema (schema ) == [
0 commit comments