@@ -52,6 +52,27 @@ def uses_the_stack_of_an_original_error():
52
52
assert e .original_error is original
53
53
assert str (e .original_error ) == "original"
54
54
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
+
55
76
def creates_new_stack_if_original_error_has_no_stack ():
56
77
try :
57
78
raise RuntimeError
@@ -108,12 +129,22 @@ def serializes_to_include_message_and_locations():
108
129
"GraphQLError('msg', locations=[SourceLocation(line=2, column=3)])"
109
130
)
110
131
132
+ def repr_includes_extensions ():
133
+ e = GraphQLError ("msg" , extensions = {"foo" : "bar" })
134
+ assert repr (e ) == ("GraphQLError('msg', extensions={'foo': 'bar'})" )
135
+
111
136
def serializes_to_include_path ():
112
137
path : List [Union [int , str ]] = ["path" , 3 , "to" , "field" ]
113
138
e = GraphQLError ("msg" , path = path )
114
139
assert e .path is path
115
140
assert repr (e ) == "GraphQLError('msg', path=['path', 3, 'to', 'field'])"
116
141
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
+
117
148
def is_hashable ():
118
149
hash (GraphQLError ("msg" ))
119
150
0 commit comments