Skip to content

Commit f98f3ff

Browse files
committed
Use less clever code to not confuse pytest 5.4
1 parent 2380aca commit f98f3ff

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

tests/type/test_validation.py

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from functools import partial
1+
from operator import attrgetter
22
from typing import Any, List, Union
33

44
from pytest import mark, raises # type: ignore
@@ -108,9 +108,8 @@ def with_modifiers(
108108
type("StringType", (str,), {"name": "StringType"}),
109109
]
110110

111-
parametrize_type = partial(
112-
mark.parametrize("type_", ids=lambda type_: type_.__class__.__name__)
113-
)
111+
112+
get_name = attrgetter("__class__.__name__")
114113

115114

116115
def schema_with_field_type(type_):
@@ -1025,7 +1024,7 @@ def _schema_with_object_field_of_type(field_type: GraphQLOutputType):
10251024
types=[SomeObjectType],
10261025
)
10271026

1028-
@parametrize_type(output_types)
1027+
@mark.parametrize("type_", output_types, ids=get_name)
10291028
def accepts_an_output_type_as_an_object_field_type(type_):
10301029
schema = _schema_with_object_field_of_type(type_)
10311030
assert validate_schema(schema) == []
@@ -1040,7 +1039,7 @@ def rejects_an_empty_object_field_type():
10401039
}
10411040
]
10421041

1043-
@parametrize_type(not_output_types)
1042+
@mark.parametrize("type_", not_output_types, ids=get_name)
10441043
def rejects_a_non_output_type_as_an_object_field_type(type_):
10451044
schema = _schema_with_object_field_of_type(type_)
10461045
assert validate_schema(schema) == [
@@ -1050,7 +1049,7 @@ def rejects_a_non_output_type_as_an_object_field_type(type_):
10501049
}
10511050
]
10521051

1053-
@parametrize_type(not_graphql_types)
1052+
@mark.parametrize("type_", not_graphql_types, ids=get_name)
10541053
def rejects_a_non_type_value_as_an_object_field_type(type_):
10551054
schema = _schema_with_object_field_of_type(type_)
10561055
assert validate_schema(schema) == [
@@ -1345,7 +1344,7 @@ def _schema_with_interface_field_of_type(field_type: GraphQLOutputType):
13451344
types=[bad_implementing_type, SomeObjectType],
13461345
)
13471346

1348-
@parametrize_type(output_types)
1347+
@mark.parametrize("type_", output_types, ids=get_name)
13491348
def accepts_an_output_type_as_an_interface_field_type(type_):
13501349
schema = _schema_with_interface_field_of_type(type_)
13511350
assert validate_schema(schema) == []
@@ -1364,7 +1363,7 @@ def rejects_an_empty_interface_field_type():
13641363
},
13651364
]
13661365

1367-
@parametrize_type(not_output_types)
1366+
@mark.parametrize("type_", not_output_types, ids=get_name)
13681367
def rejects_a_non_output_type_as_an_interface_field_type(type_):
13691368
schema = _schema_with_interface_field_of_type(type_)
13701369
assert validate_schema(schema) == [
@@ -1378,7 +1377,7 @@ def rejects_a_non_output_type_as_an_interface_field_type(type_):
13781377
},
13791378
]
13801379

1381-
@parametrize_type(not_graphql_types)
1380+
@mark.parametrize("type_", not_graphql_types, ids=get_name)
13821381
def rejects_a_non_type_value_as_an_interface_field_type(type_):
13831382
schema = _schema_with_interface_field_of_type(type_)
13841383
assert validate_schema(schema) == [
@@ -1498,7 +1497,7 @@ def _schema_with_arg_of_type(arg_type: GraphQLInputType):
14981497
],
14991498
)
15001499

1501-
@parametrize_type(input_types)
1500+
@mark.parametrize("type_", input_types, ids=get_name)
15021501
def accepts_an_input_type_as_a_field_arg_type(type_):
15031502
schema = _schema_with_arg_of_type(type_)
15041503
assert validate_schema(schema) == []
@@ -1517,7 +1516,7 @@ def rejects_an_empty_field_arg_type():
15171516
},
15181517
]
15191518

1520-
@parametrize_type(not_input_types)
1519+
@mark.parametrize("type_", not_input_types, ids=get_name)
15211520
def rejects_a_non_input_type_as_a_field_arg_type(type_):
15221521
schema = _schema_with_arg_of_type(type_)
15231522
assert validate_schema(schema) == [
@@ -1531,7 +1530,7 @@ def rejects_a_non_input_type_as_a_field_arg_type(type_):
15311530
},
15321531
]
15331532

1534-
@parametrize_type(not_graphql_types)
1533+
@mark.parametrize("type_", not_graphql_types, ids=get_name)
15351534
def rejects_a_non_type_value_as_a_field_arg_type(type_):
15361535
schema = _schema_with_arg_of_type(type_)
15371536
assert validate_schema(schema) == [
@@ -1616,8 +1615,8 @@ def _schema_with_input_field_of_type(input_field_type: GraphQLInputType):
16161615
)
16171616
)
16181617

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_):
16211620
schema = _schema_with_input_field_of_type(type_)
16221621
assert validate_schema(schema) == []
16231622

@@ -1631,7 +1630,7 @@ def rejects_an_empty_input_field_type():
16311630
}
16321631
]
16331632

1634-
@parametrize_type(not_input_types)
1633+
@mark.parametrize("type_", not_input_types, ids=get_name)
16351634
def rejects_a_non_input_type_as_an_input_field_type(type_):
16361635
schema = _schema_with_input_field_of_type(type_)
16371636
assert validate_schema(schema) == [
@@ -1641,7 +1640,7 @@ def rejects_a_non_input_type_as_an_input_field_type(type_):
16411640
}
16421641
]
16431642

1644-
@parametrize_type(not_graphql_types)
1643+
@mark.parametrize("type_", not_graphql_types, ids=get_name)
16451644
def rejects_a_non_type_value_as_an_input_field_type(type_):
16461645
schema = _schema_with_input_field_of_type(type_)
16471646
assert validate_schema(schema) == [

0 commit comments

Comments
 (0)