@@ -52,6 +52,27 @@ def uses_the_stack_of_an_original_error():
5252 assert e .original_error is original
5353 assert str (e .original_error ) == "original"
5454
55+ def passes_the_context_of_an_original_error ():
56+ context = ValueError ("cause" )
57+ try :
58+ raise context
59+ except ValueError :
60+ try :
61+ raise RuntimeError ("effect" )
62+ except RuntimeError as runtime_error :
63+ original = runtime_error
64+ e = GraphQLError ("msg" , original_error = original )
65+ assert e .__context__ is context
66+
67+ def passes_the_cause_of_an_original_error ():
68+ cause = ValueError ("cause" )
69+ try :
70+ raise RuntimeError ("effect" ) from cause
71+ except RuntimeError as runtime_error :
72+ original = runtime_error
73+ e = GraphQLError ("msg" , original_error = original )
74+ assert e .__cause__ is cause
75+
5576 def creates_new_stack_if_original_error_has_no_stack ():
5677 try :
5778 raise RuntimeError
@@ -108,12 +129,22 @@ def serializes_to_include_message_and_locations():
108129 "GraphQLError('msg', locations=[SourceLocation(line=2, column=3)])"
109130 )
110131
132+ def repr_includes_extensions ():
133+ e = GraphQLError ("msg" , extensions = {"foo" : "bar" })
134+ assert repr (e ) == ("GraphQLError('msg', extensions={'foo': 'bar'})" )
135+
111136 def serializes_to_include_path ():
112137 path : List [Union [int , str ]] = ["path" , 3 , "to" , "field" ]
113138 e = GraphQLError ("msg" , path = path )
114139 assert e .path is path
115140 assert repr (e ) == "GraphQLError('msg', path=['path', 3, 'to', 'field'])"
116141
142+ def always_stores_path_as_list ():
143+ path : List [Union [int , str ]] = ["path" , 3 , "to" , "field" ]
144+ e = GraphQLError ("msg," , path = tuple (path ))
145+ assert isinstance (e .path , list )
146+ assert e .path == path
147+
117148 def is_hashable ():
118149 hash (GraphQLError ("msg" ))
119150
0 commit comments