diff -r f8e435d6a801 Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py Sun Aug 05 00:33:10 2012 +0200 +++ b/Lib/test/test_httpservers.py Sun Aug 05 00:40:22 2012 +0100 @@ -70,6 +70,9 @@ self.connection.request(method, uri, body, headers) return self.connection.getresponse() + def _fix_newline(self, b): + return b"\n".join(b.split(bytes(os.linesep, "ascii"))) + class BaseHTTPServerTestCase(BaseTestCase): class request_handler(NoLogRequestHandler, BaseHTTPRequestHandler): @@ -411,7 +414,8 @@ def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), - (res.read(), res.getheader('Content-type'), res.status)) + (self._fix_newline(res.read()), res.getheader('Content-type'), + res.status)) def test_post(self): params = urllib.parse.urlencode( @@ -419,7 +423,8 @@ headers = {'Content-type' : 'application/x-www-form-urlencoded'} res = self.request('/cgi-bin/file2.py', 'POST', params, headers) - self.assertEqual(res.read(), b'1, python, 123456\n') + self.assertEqual(self._fix_newline(res.read()), + b'1, python, 123456\n') def test_invaliduri(self): res = self.request('/cgi-bin/invalid') @@ -431,20 +436,23 @@ base64.b64encode(b'username:pass')} res = self.request('/cgi-bin/file1.py', 'GET', headers=headers) self.assertEqual((b'Hello World\n', 'text/html', 200), - (res.read(), res.getheader('Content-type'), res.status)) + (self._fix_newline(res.read()), res.getheader('Content-type'), + res.status)) def test_no_leading_slash(self): # http://bugs.python.org/issue2254 res = self.request('cgi-bin/file1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), - (res.read(), res.getheader('Content-type'), res.status)) + (self._fix_newline(res.read()), res.getheader('Content-type'), + res.status)) def test_os_environ_is_not_altered(self): signature = "Test CGI Server" os.environ['SERVER_SOFTWARE'] = signature res = self.request('/cgi-bin/file1.py') self.assertEqual((b'Hello World\n', 'text/html', 200), - (res.read(), res.getheader('Content-type'), res.status)) + (self._fix_newline(res.read()), res.getheader('Content-type'), + res.status)) self.assertEqual(os.environ['SERVER_SOFTWARE'], signature)