@@ -403,12 +403,12 @@ def rejects_an_object_type_with_incorrectly_typed_field_args():
403
403
404
404
def does_not_accept_is_deprecated_instead_of_deprecation_reason_on_field ():
405
405
kwargs = dict (is_deprecated = True )
406
- with raises (TypeError ) as exc_info :
406
+ with raises (
407
+ TypeError , match = "got an unexpected keyword argument 'is_deprecated'"
408
+ ):
407
409
GraphQLObjectType (
408
410
"OldObject" , {"field" : GraphQLField (GraphQLString , ** kwargs )}
409
411
)
410
- msg = str (exc_info .value )
411
- assert "got an unexpected keyword argument 'is_deprecated'" in msg
412
412
413
413
414
414
def describe_object_interfaces_must_be_a_sequence ():
@@ -558,11 +558,11 @@ def accepts_a_scalar_type_defining_serialize():
558
558
schema_with_field_type (GraphQLScalarType ("SomeScalar" , lambda : None ))
559
559
560
560
def rejects_a_scalar_type_not_defining_serialize ():
561
- with raises (TypeError ) as exc_info :
561
+ with raises (
562
+ TypeError , match = "missing 1 required positional argument: 'serialize'"
563
+ ):
562
564
# noinspection PyArgumentList
563
565
schema_with_field_type (GraphQLScalarType ("SomeScalar" ))
564
- msg = str (exc_info .value )
565
- assert "missing 1 required positional argument: 'serialize'" in msg
566
566
with raises (TypeError ) as exc_info :
567
567
# noinspection PyTypeChecker
568
568
schema_with_field_type (GraphQLScalarType ("SomeScalar" , None ))
@@ -663,11 +663,9 @@ def accepts_a_union_type_with_function_returning_a_list_of_types():
663
663
schema_with_field_type (GraphQLUnionType ("SomeUnion" , lambda : [ObjectType ]))
664
664
665
665
def accepts_a_union_type_without_types ():
666
- with raises (TypeError ) as exc_info :
666
+ with raises (TypeError , match = "missing 1 required positional argument: 'types'" ) :
667
667
# noinspection PyArgumentList
668
668
schema_with_field_type (GraphQLUnionType ("SomeUnion" ))
669
- msg = str (exc_info .value )
670
- assert "missing 1 required positional argument: 'types'" in msg
671
669
schema_with_field_type (GraphQLUnionType ("SomeUnion" , None ))
672
670
schema_with_field_type (GraphQLUnionType ("SomeUnion" , []))
673
671
@@ -726,14 +724,12 @@ def rejects_an_input_object_type_with_incorrect_fields_function():
726
724
727
725
def describe_type_system_input_objects_fields_must_not_have_resolvers ():
728
726
def rejects_an_input_object_type_with_resolvers ():
729
- with raises (TypeError ) as exc_info :
727
+ with raises (TypeError , match = "got an unexpected keyword argument 'resolve'" ) :
730
728
# noinspection PyArgumentList
731
729
GraphQLInputObjectType (
732
730
"SomeInputObject" ,
733
731
{"f" : GraphQLInputField (GraphQLString , resolve = lambda : 0 )},
734
732
)
735
- msg = str (exc_info .value )
736
- assert "got an unexpected keyword argument 'resolve'" in msg
737
733
input_obj_type = GraphQLInputObjectType (
738
734
"SomeInputObject" , {"f" : GraphQLField (GraphQLString , resolve = lambda : 0 )}
739
735
)
@@ -746,13 +742,11 @@ def rejects_an_input_object_type_with_resolvers():
746
742
)
747
743
748
744
def rejects_an_input_object_type_with_resolver_constant ():
749
- with raises (TypeError ) as exc_info :
745
+ with raises (TypeError , match = "got an unexpected keyword argument 'resolve'" ) :
750
746
# noinspection PyArgumentList
751
747
GraphQLInputObjectType (
752
748
"SomeInputObject" , {"f" : GraphQLInputField (GraphQLString , resolve = {})}
753
749
)
754
- msg = str (exc_info .value )
755
- assert "got an unexpected keyword argument 'resolve'" in msg
756
750
757
751
758
752
def describe_type_system_enum_types_must_be_well_defined ():
@@ -781,11 +775,11 @@ def rejects_an_enum_type_with_incorrectly_typed_values():
781
775
)
782
776
783
777
def does_not_allow_is_deprecated ():
784
- with raises (TypeError ) as exc_info :
778
+ with raises (
779
+ TypeError , match = "got an unexpected keyword argument 'is_deprecated'"
780
+ ):
785
781
# noinspection PyArgumentList
786
782
GraphQLEnumType ("SomeEnum" , {"FOO" : GraphQLEnumValue (is_deprecated = True )})
787
- msg = str (exc_info .value )
788
- assert "got an unexpected keyword argument 'is_deprecated'" in msg
789
783
790
784
791
785
def describe_type_system_list_must_accept_only_types ():
0 commit comments