Skip to content

Commit f26bb2e

Browse files
committed
Fixed flaky test
1 parent 199c711 commit f26bb2e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

graphql/execution/tests/test_executor_thread.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ def asyncReturnError(self):
190190
)
191191
)
192192

193+
def sort_key(item):
194+
locations = item['locations'][0]
195+
return (locations['line'], locations['column'])
196+
193197
def handle_results(result):
194198
assert result.data == {
195199
'async': 'async',
@@ -201,15 +205,15 @@ def handle_results(result):
201205
'syncReturnError': None,
202206
'syncReturnErrorList': ['sync0', None, 'sync2', None]
203207
}
204-
assert list(map(format_error, result.errors)) == [
208+
assert sorted(list(map(format_error, result.errors)), key=sort_key) == sorted([
205209
{'locations': [{'line': 4, 'column': 9}], 'message': 'Error getting syncError'},
206210
{'locations': [{'line': 5, 'column': 9}], 'message': 'Error getting syncReturnError'},
207211
{'locations': [{'line': 6, 'column': 9}], 'message': 'Error getting syncReturnErrorList1'},
208212
{'locations': [{'line': 6, 'column': 9}], 'message': 'Error getting syncReturnErrorList3'},
209213
{'locations': [{'line': 8, 'column': 9}], 'message': 'Error getting asyncReject'},
210214
{'locations': [{'line': 9, 'column': 9}], 'message': 'An unknown error occurred.'},
211215
{'locations': [{'line': 10, 'column': 9}], 'message': 'Error getting asyncReturnError'}
212-
]
216+
], key=sort_key)
213217

214218
handle_results(execute(schema, ast, Data(), executor=ThreadExecutor()))
215219

0 commit comments

Comments
 (0)