@@ -174,30 +174,30 @@ def test_head_method_serializes_no_content(self):
174174
175175def test_default_renderer_serializes_content_on_accept_any (self ):
176176"""If the Accept header is set to */* the default renderer should serialize the response."""
177- resp = self .client .get ('/' ,HTTP_ACCEPT = '*/*' )
177+ resp = self .client .get ('/' ,headers = { "accept" : '*/*' } )
178178self .assertEqual (resp ['Content-Type' ],RendererA .media_type + '; charset=utf-8' )
179179self .assertEqual (resp .content ,RENDERER_A_SERIALIZER (DUMMYCONTENT ))
180180self .assertEqual (resp .status_code ,DUMMYSTATUS )
181181
182182def test_specified_renderer_serializes_content_default_case (self ):
183183"""If the Accept header is set the specified renderer should serialize the response.
184184 (In this case we check that works for the default renderer)"""
185- resp = self .client .get ('/' ,HTTP_ACCEPT = RendererA .media_type )
185+ resp = self .client .get ('/' ,headers = { "accept" : RendererA .media_type } )
186186self .assertEqual (resp ['Content-Type' ],RendererA .media_type + '; charset=utf-8' )
187187self .assertEqual (resp .content ,RENDERER_A_SERIALIZER (DUMMYCONTENT ))
188188self .assertEqual (resp .status_code ,DUMMYSTATUS )
189189
190190def test_specified_renderer_serializes_content_non_default_case (self ):
191191"""If the Accept header is set the specified renderer should serialize the response.
192192 (In this case we check that works for a non-default renderer)"""
193- resp = self .client .get ('/' ,HTTP_ACCEPT = RendererB .media_type )
193+ resp = self .client .get ('/' ,headers = { "accept" : RendererB .media_type } )
194194self .assertEqual (resp ['Content-Type' ],RendererB .media_type + '; charset=utf-8' )
195195self .assertEqual (resp .content ,RENDERER_B_SERIALIZER (DUMMYCONTENT ))
196196self .assertEqual (resp .status_code ,DUMMYSTATUS )
197197
198198def test_unsatisfiable_accept_header_on_request_returns_406_status (self ):
199199"""If the Accept header is unsatisfiable we should return a 406 Not Acceptable response."""
200- resp = self .client .get ('/' ,HTTP_ACCEPT = 'foo/bar' )
200+ resp = self .client .get ('/' ,headers = { "accept" : 'foo/bar' } )
201201self .assertEqual (resp .status_code ,status .HTTP_406_NOT_ACCEPTABLE )
202202
203203def test_specified_renderer_serializes_content_on_format_query (self ):
@@ -228,14 +228,14 @@ def test_specified_renderer_is_used_on_format_query_with_matching_accept(self):
228228RendererB .format
229229 )
230230resp = self .client .get ('/' + param ,
231- HTTP_ACCEPT = RendererB .media_type )
231+ headers = { "accept" : RendererB .media_type } )
232232self .assertEqual (resp ['Content-Type' ],RendererB .media_type + '; charset=utf-8' )
233233self .assertEqual (resp .content ,RENDERER_B_SERIALIZER (DUMMYCONTENT ))
234234self .assertEqual (resp .status_code ,DUMMYSTATUS )
235235
236236def test_parse_error_renderers_browsable_api (self ):
237237"""Invalid data should still render the browsable API correctly."""
238- resp = self .client .post ('/parseerror' ,data = 'foobar' ,content_type = 'application/json' ,HTTP_ACCEPT = 'text/html' )
238+ resp = self .client .post ('/parseerror' ,data = 'foobar' ,content_type = 'application/json' ,headers = { "accept" : 'text/html' } )
239239self .assertEqual (resp ['Content-Type' ],'text/html; charset=utf-8' )
240240self .assertEqual (resp .status_code ,status .HTTP_400_BAD_REQUEST )
241241
@@ -714,13 +714,13 @@ class DummyView:
714714assert result is None
715715
716716def test_extra_actions_dropdown (self ):
717- resp = self .client .get ('/api/examples/' ,HTTP_ACCEPT = 'text/html' )
717+ resp = self .client .get ('/api/examples/' ,headers = { "accept" : 'text/html' } )
718718assert 'id="extra-actions-menu"' in resp .content .decode ()
719719assert '/api/examples/list_action/' in resp .content .decode ()
720720assert '>Extra list action<' in resp .content .decode ()
721721
722722def test_extra_actions_dropdown_not_authed (self ):
723- resp = self .client .get ('/api/unauth-examples/' ,HTTP_ACCEPT = 'text/html' )
723+ resp = self .client .get ('/api/unauth-examples/' ,headers = { "accept" : 'text/html' } )
724724assert 'id="extra-actions-menu"' not in resp .content .decode ()
725725assert '/api/examples/list_action/' not in resp .content .decode ()
726726assert '>Extra list action<' not in resp .content .decode ()