Tests: use "data" parameter in Request() to send body.
This commit is contained in:
@@ -59,9 +59,8 @@ def application(environ, start_response):
|
|||||||
r = unit.TestUnitHTTP.post(headers={
|
r = unit.TestUnitHTTP.post(headers={
|
||||||
'Host': 'localhost',
|
'Host': 'localhost',
|
||||||
'Content-Type': 'text/html',
|
'Content-Type': 'text/html',
|
||||||
'Content-Length': str(len(body)),
|
|
||||||
'Custom-Header': 'blah'
|
'Custom-Header': 'blah'
|
||||||
}, body=body)
|
}, data=body)
|
||||||
|
|
||||||
self.assertEqual(r.status_code, 200, 'status')
|
self.assertEqual(r.status_code, 200, 'status')
|
||||||
self.assertEqual(r.headers['Content-Length'], str(len(body)),
|
self.assertEqual(r.headers['Content-Length'], str(len(body)),
|
||||||
|
|||||||
10
test/unit.py
10
test/unit.py
@@ -215,15 +215,13 @@ class TestUnitHTTP():
|
|||||||
host = '127.0.0.1:7080' if 'host' not in kwargs else kwargs['host']
|
host = '127.0.0.1:7080' if 'host' not in kwargs else kwargs['host']
|
||||||
uri = '/' if 'uri' not in kwargs else kwargs['uri']
|
uri = '/' if 'uri' not in kwargs else kwargs['uri']
|
||||||
sess = Session() if 'sess' not in kwargs else kwargs['sess']
|
sess = Session() if 'sess' not in kwargs else kwargs['sess']
|
||||||
body = None if 'body' not in kwargs else kwargs['body']
|
data = None if 'data' not in kwargs else kwargs['data']
|
||||||
headers = None if 'headers' not in kwargs else kwargs['headers']
|
headers = None if 'headers' not in kwargs else kwargs['headers']
|
||||||
|
|
||||||
req = Request('POST', 'http://' + host + uri, headers=headers)
|
req = Request(method, 'http://' + host + uri, data=data,
|
||||||
prepped = req.prepare()
|
headers=headers)
|
||||||
|
|
||||||
prepped.body = body
|
r = sess.send(req.prepare())
|
||||||
|
|
||||||
r = sess.send(prepped)
|
|
||||||
|
|
||||||
if 'keep' not in kwargs:
|
if 'keep' not in kwargs:
|
||||||
sess.close()
|
sess.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user