@@ -72,14 +72,23 @@ async def test_file_response(self):
7272 response_start = await communicator .receive_output ()
7373 self .assertEqual (response_start ['type' ], 'http.response.start' )
7474 self .assertEqual (response_start ['status' ], 200 )
75- self .assertEqual (
76- set (response_start ['headers' ]),
77- {
78- (b'Content-Length' , str (len (test_file_contents )).encode ('ascii' )),
79- (b'Content-Type' , b'text/plain' if sys .platform == 'win32' else b'text/x-python' ),
80- (b'Content-Disposition' , b'inline; filename="urls.py"' ),
81- },
82- )
75+ headers = response_start ['headers' ]
76+ self .assertEqual (len (headers ), 3 )
77+ expected_headers = {
78+ b'Content-Length' : str (len (test_file_contents )).encode ('ascii' ),
79+ b'Content-Type' : b'text/x-python' ,
80+ b'Content-Disposition' : b'inline; filename="urls.py"' ,
81+ }
82+ for key , value in headers :
83+ try :
84+ self .assertEqual (value , expected_headers [key ])
85+ except AssertionError :
86+ # Windows registry may not be configured with correct
87+ # mimetypes.
88+ if sys .platform == 'win32' and key == b'Content-Type' :
89+ self .assertEqual (value , b'text/plain' )
90+ else :
91+ raise
8392 response_body = await communicator .receive_output ()
8493 self .assertEqual (response_body ['type' ], 'http.response.body' )
8594 self .assertEqual (response_body ['body' ], test_file_contents )
0 commit comments