File tree 2 files changed +13
-10
lines changed
2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change
1
+ from collections import Mapping
1
2
from functools import partial
2
3
from cgi import parse_header
3
4
@@ -47,8 +48,13 @@ def get_root_value(self, request):
47
48
return self .root_value
48
49
49
50
def get_context (self , request ):
50
- context = self .context .copy () if self .context else {}
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 :
52
58
context .update ({'request' : request })
53
59
return context
54
60
Original file line number Diff line number Diff line change @@ -484,11 +484,8 @@ def test_supports_pretty_printing(app):
484
484
485
485
486
486
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': {}}"
492
489
493
490
494
491
@parametrize_sync_async_app_test ('app' )
@@ -499,9 +496,9 @@ def test_post_multipart_data(app):
499
496
'Content-Disposition: form-data; name="query"\r \n ' +
500
497
'\r \n ' +
501
498
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 ' +
505
502
'\r \n ' +
506
503
'\r \n ' +
507
504
'------sanicgraphql--\r \n '
You can’t perform that action at this time.
0 commit comments