mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Merged revisions 79100 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79100 | florent.xicluna | 2010-03-19 19:34:55 +0100 (ven, 19 mar 2010) | 2 lines Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown. ........
This commit is contained in:
parent
fb60f8002c
commit
9b86b9a086
8 changed files with 75 additions and 80 deletions
|
@ -104,42 +104,42 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
def test_command(self):
|
||||
self.con.request('GET', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_request_line_trimming(self):
|
||||
self.con._http_vsn_str = 'HTTP/1.1\n'
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_version_bogus(self):
|
||||
self.con._http_vsn_str = 'FUBAR'
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_version_digits(self):
|
||||
self.con._http_vsn_str = 'HTTP/9.9.9'
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_version_none_get(self):
|
||||
self.con._http_vsn_str = ''
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_version_none(self):
|
||||
self.con._http_vsn_str = ''
|
||||
self.con.putrequest('PUT', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_version_invalid(self):
|
||||
self.con._http_vsn = 99
|
||||
|
@ -147,21 +147,21 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
self.con.putrequest('GET', '/')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 505)
|
||||
self.assertEqual(res.status, 505)
|
||||
|
||||
def test_send_blank(self):
|
||||
self.con._http_vsn_str = ''
|
||||
self.con.putrequest('', '')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 400)
|
||||
self.assertEqual(res.status, 400)
|
||||
|
||||
def test_header_close(self):
|
||||
self.con.putrequest('GET', '/')
|
||||
self.con.putheader('Connection', 'close')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_head_keep_alive(self):
|
||||
self.con._http_vsn_str = 'HTTP/1.1'
|
||||
|
@ -169,28 +169,28 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
self.con.putheader('Connection', 'keep-alive')
|
||||
self.con.endheaders()
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 501)
|
||||
self.assertEqual(res.status, 501)
|
||||
|
||||
def test_handler(self):
|
||||
self.con.request('TEST', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 204)
|
||||
self.assertEqual(res.status, 204)
|
||||
|
||||
def test_return_header_keep_alive(self):
|
||||
self.con.request('KEEP', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.getheader('Connection'), 'keep-alive')
|
||||
self.assertEqual(res.getheader('Connection'), 'keep-alive')
|
||||
self.con.request('TEST', '/')
|
||||
|
||||
def test_internal_key_error(self):
|
||||
self.con.request('KEYERROR', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 999)
|
||||
self.assertEqual(res.status, 999)
|
||||
|
||||
def test_return_custom_status(self):
|
||||
self.con.request('CUSTOM', '/')
|
||||
res = self.con.getresponse()
|
||||
self.assertEquals(res.status, 999)
|
||||
self.assertEqual(res.status, 999)
|
||||
|
||||
|
||||
class SimpleHTTPServerTestCase(BaseTestCase):
|
||||
|
@ -222,8 +222,8 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
|||
def check_status_and_reason(self, response, status, data=None):
|
||||
body = response.read()
|
||||
self.assertTrue(response)
|
||||
self.assertEquals(response.status, status)
|
||||
self.assertTrue(response.reason != None)
|
||||
self.assertEqual(response.status, status)
|
||||
self.assertIsNotNone(response.reason)
|
||||
if data:
|
||||
self.assertEqual(data, body)
|
||||
|
||||
|
@ -284,8 +284,8 @@ print("Content-type: text/html")
|
|||
print()
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),\
|
||||
form.getfirst("bacon")))
|
||||
print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
|
||||
form.getfirst("bacon")))
|
||||
"""
|
||||
|
||||
class CGIHTTPServerTestCase(BaseTestCase):
|
||||
|
@ -356,14 +356,14 @@ class CGIHTTPServerTestCase(BaseTestCase):
|
|||
server._url_collapse_path_split, path)
|
||||
else:
|
||||
actual = server._url_collapse_path_split(path)
|
||||
self.assertEquals(expected, actual,
|
||||
msg='path = %r\nGot: %r\nWanted: %r' % (
|
||||
path, actual, expected))
|
||||
self.assertEqual(expected, actual,
|
||||
msg='path = %r\nGot: %r\nWanted: %r' %
|
||||
(path, actual, expected))
|
||||
|
||||
def test_headers_and_content(self):
|
||||
res = self.request('/cgi-bin/file1.py')
|
||||
self.assertEquals((b'Hello World\n', 'text/html', 200), \
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
self.assertEqual((b'Hello World\n', 'text/html', 200),
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
|
||||
def test_post(self):
|
||||
params = urllib.parse.urlencode(
|
||||
|
@ -371,24 +371,24 @@ class CGIHTTPServerTestCase(BaseTestCase):
|
|||
headers = {'Content-type' : 'application/x-www-form-urlencoded'}
|
||||
res = self.request('/cgi-bin/file2.py', 'POST', params, headers)
|
||||
|
||||
self.assertEquals(res.read(), b'1, python, 123456\n')
|
||||
self.assertEqual(res.read(), b'1, python, 123456\n')
|
||||
|
||||
def test_invaliduri(self):
|
||||
res = self.request('/cgi-bin/invalid')
|
||||
res.read()
|
||||
self.assertEquals(res.status, 404)
|
||||
self.assertEqual(res.status, 404)
|
||||
|
||||
def test_authorization(self):
|
||||
headers = {b'Authorization' : b'Basic ' +
|
||||
base64.b64encode(b'username:pass')}
|
||||
res = self.request('/cgi-bin/file1.py', 'GET', headers=headers)
|
||||
self.assertEquals((b'Hello World\n', 'text/html', 200), \
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
self.assertEqual((b'Hello World\n', 'text/html', 200),
|
||||
(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.assertEquals((b'Hello World\n', 'text/html', 200),
|
||||
self.assertEqual((b'Hello World\n', 'text/html', 200),
|
||||
(res.read(), res.getheader('Content-type'), res.status))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue