summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httpservers.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-19 18:34:55 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-19 18:34:55 (GMT)
commitbc27c6a5aa75a8f52304ecd311fbadef4ec621ce (patch)
tree5634ee9187192196c6e565e491144e2574c436ef /Lib/test/test_httpservers.py
parent4854c969fb6f42b3d67e14977bc3f0f6f3ec70c9 (diff)
downloadcpython-bc27c6a5aa75a8f52304ecd311fbadef4ec621ce.zip
cpython-bc27c6a5aa75a8f52304ecd311fbadef4ec621ce.tar.gz
cpython-bc27c6a5aa75a8f52304ecd311fbadef4ec621ce.tar.bz2
Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown.
Diffstat (limited to 'Lib/test/test_httpservers.py')
-rw-r--r--Lib/test/test_httpservers.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 87d5588..7bd0fe8 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -103,42 +103,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
@@ -146,21 +146,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'
@@ -168,28 +168,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):
@@ -221,8 +221,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)
@@ -283,8 +283,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):
@@ -355,38 +355,38 @@ class CGIHTTPServerTestCase(BaseTestCase):
CGIHTTPServer._url_collapse_path_split, path)
else:
actual = CGIHTTPServer._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(('Hello World\n', 'text/html', 200), \
- (res.read(), res.getheader('Content-type'), res.status))
+ self.assertEqual(('Hello World\n', 'text/html', 200),
+ (res.read(), res.getheader('Content-type'), res.status))
def test_post(self):
params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456})
headers = {'Content-type' : 'application/x-www-form-urlencoded'}
res = self.request('/cgi-bin/file2.py', 'POST', params, headers)
- self.assertEquals(res.read(), '1, python, 123456\n')
+ self.assertEqual(res.read(), '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 = {'Authorization' : 'Basic %s' % \
- base64.b64encode('username:pass')}
+ headers = {'Authorization' : 'Basic %s' %
+ base64.b64encode('username:pass')}
res = self.request('/cgi-bin/file1.py', 'GET', headers=headers)
- self.assertEquals(('Hello World\n', 'text/html', 200), \
- (res.read(), res.getheader('Content-type'), res.status))
+ self.assertEqual(('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(('Hello World\n', 'text/html', 200),
+ self.assertEqual(('Hello World\n', 'text/html', 200),
(res.read(), res.getheader('Content-type'), res.status))