Made tests compatible with tornado 4.5.3

pull/58/head
Sheng 2019-02-21 17:32:55 +08:00
parent b25fbd7b57
commit 9fbd5d325f
1 changed files with 5 additions and 10 deletions

View File

@ -56,7 +56,7 @@ class TestAppBase(AsyncHTTPTestCase):
self.assertIsNone(data['status']) self.assertIsNone(data['status'])
def fetch_request(self, url, method='GET', body='', headers={}, sync=True): def fetch_request(self, url, method='GET', body='', headers={}, sync=True):
if url.startswith('/'): if not sync and url.startswith('/'):
url = self.get_url(url) url = self.get_url(url)
if isinstance(body, dict): if isinstance(body, dict):
@ -403,7 +403,6 @@ class TestAppBasic(TestAppBase):
yield self.async_post(url, body, headers=headers) yield self.async_post(url, body, headers=headers)
self.assertIn('Bad Request', ctx.exception.message) self.assertIn('Bad Request', ctx.exception.message)
@tornado.testing.gen_test
def test_app_post_form_with_large_body_size_by_multipart_form(self): def test_app_post_form_with_large_body_size_by_multipart_form(self):
privatekey = 'h' * (2 * max_body_size) privatekey = 'h' * (2 * max_body_size)
files = [('privatekey', 'user_rsa_key', privatekey)] files = [('privatekey', 'user_rsa_key', privatekey)]
@ -412,18 +411,14 @@ class TestAppBasic(TestAppBase):
headers = { headers = {
'Content-Type': content_type, 'content-length': str(len(body)) 'Content-Type': content_type, 'content-length': str(len(body))
} }
response = self.sync_post('/', body, headers=headers)
self.assertIn(response.code, [400, 599])
with self.assertRaises(HTTPError) as ctx:
yield self.async_post('/', body, headers=headers)
self.assertIn('Bad Request', ctx.exception.message)
@tornado.testing.gen_test
def test_app_post_form_with_large_body_size_by_urlencoded_form(self): def test_app_post_form_with_large_body_size_by_urlencoded_form(self):
privatekey = 'h' * (2 * max_body_size) privatekey = 'h' * (2 * max_body_size)
body = self.body + '&privatekey=' + privatekey body = self.body + '&privatekey=' + privatekey
with self.assertRaises(HTTPError) as ctx: response = self.sync_post('/', body)
yield self.async_post('/', body) self.assertIn(response.code, [400, 599])
self.assertIn('Bad Request', ctx.exception.message)
@tornado.testing.gen_test @tornado.testing.gen_test
def test_app_with_user_keyonly_for_bad_authentication_type(self): def test_app_with_user_keyonly_for_bad_authentication_type(self):