summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrey Zelenkov <zelenkov@nginx.com>2018-01-15 19:59:47 +0300
committerAndrey Zelenkov <zelenkov@nginx.com>2018-01-15 19:59:47 +0300
commit819b43fc2da414c9132c6061eabf063ae08c36dc (patch)
tree1e0f292c207d491774542a8615041847cee9ecfa
parent263741fb445468eb7123bad0f7c46c1fdf6087a8 (diff)
downloadunit-819b43fc2da414c9132c6061eabf063ae08c36dc.tar.gz
unit-819b43fc2da414c9132c6061eabf063ae08c36dc.tar.bz2
Tests: use "data" parameter in Request() to send body.
-rw-r--r--test/test_python_application.py3
-rw-r--r--test/unit.py10
2 files changed, 5 insertions, 8 deletions
diff --git a/test/test_python_application.py b/test/test_python_application.py
index a693002b..5066624a 100644
--- a/test/test_python_application.py
+++ b/test/test_python_application.py
@@ -59,9 +59,8 @@ def application(environ, start_response):
r = unit.TestUnitHTTP.post(headers={
'Host': 'localhost',
'Content-Type': 'text/html',
- 'Content-Length': str(len(body)),
'Custom-Header': 'blah'
- }, body=body)
+ }, data=body)
self.assertEqual(r.status_code, 200, 'status')
self.assertEqual(r.headers['Content-Length'], str(len(body)),
diff --git a/test/unit.py b/test/unit.py
index a119b030..86ff308d 100644
--- a/test/unit.py
+++ b/test/unit.py
@@ -215,15 +215,13 @@ class TestUnitHTTP():
host = '127.0.0.1:7080' if 'host' not in kwargs else kwargs['host']
uri = '/' if 'uri' not in kwargs else kwargs['uri']
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']
- req = Request('POST', 'http://' + host + uri, headers=headers)
- prepped = req.prepare()
+ req = Request(method, 'http://' + host + uri, data=data,
+ headers=headers)
- prepped.body = body
-
- r = sess.send(prepped)
+ r = sess.send(req.prepare())
if 'keep' not in kwargs:
sess.close()