File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 1+ from collections import Mapping
12from functools import partial
23from cgi import parse_header
34
@@ -47,8 +48,13 @@ def get_root_value(self, request):
4748 return self .root_value
4849
4950 def get_context (self , request ):
50- context = self .context or {}
51- if isinstance (context , dict ) and 'request' not in context :
51+ context = (
52+ self .context .copy ()
53+ if self .context and
54+ isinstance (self .context , Mapping )
55+ else {}
56+ )
57+ if isinstance (context , Mapping ) and 'request' not in context :
5258 context .update ({'request' : request })
5359 return context
5460
Original file line number Diff line number Diff line change @@ -484,11 +484,8 @@ def test_supports_pretty_printing(app):
484484
485485
486486 assert response .status == 200
487- assert response_json (response ) == {
488- 'data' : {
489- 'context' : 'CUSTOM CONTEXT'
490- }
491- }
487+ assert 'data' in response_json (response )
488+ assert response_json (response )['data' ]['context' ] == "{'request': {}}"
492489
493490
494491@parametrize_sync_async_app_test ('app' )
@@ -499,9 +496,9 @@ def test_post_multipart_data(app):
499496 'Content-Disposition: form-data; name="query"\r \n ' +
500497 '\r \n ' +
501498 query + '\r \n ' +
502- '------sanicgraphql--\r \n ' +
503- 'Content-Type: text/plain; charset=utf-8\r \n ' +
504- 'Content-Disposition: form-data; name="file"; filename="text1.txt"; filename*=utf-8\' \' text1.txt\r \n ' +
499+ '------sanicgraphql--\r \n ' +
500+ 'Content-Type: text/plain; charset=utf-8\r \n ' +
501+ 'Content-Disposition: form-data; name="file"; filename="text1.txt"; filename*=utf-8\' \' text1.txt\r \n ' +
505502 '\r \n ' +
506503 '\r \n ' +
507504 '------sanicgraphql--\r \n '
You can’t perform that action at this time.
0 commit comments