summaryrefslogtreecommitdiff
path: root/tests/test_request_form.py
diff options
context:
space:
mode:
authorMiro Hron?ok <miro@hroncok.cz>2018-06-08 18:49:42 +0200
committerMiro Hron?ok <miro@hroncok.cz>2018-06-08 18:49:42 +0200
commitbb9bdf7e5b5cb0d3458242c5b8ba6134efb282a4 (patch)
treee3f03e7ce1f234e0c91075da6d0b56040f693162 /tests/test_request_form.py
downloadpaste-git-bb9bdf7e5b5cb0d3458242c5b8ba6134efb282a4.tar.gz
Don't raise StopIteration from generator, return instead
See https://www.python.org/dev/peps/pep-0479/
Diffstat (limited to 'tests/test_request_form.py')
-rw-r--r--tests/test_request_form.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_request_form.py b/tests/test_request_form.py
new file mode 100644
index 0000000..cf43721
--- /dev/null
+++ b/tests/test_request_form.py
@@ -0,0 +1,36 @@
+import six
+
+from paste.request import *
+from paste.util.multidict import MultiDict
+
+def test_parse_querystring():
+ e = {'QUERY_STRING': 'a=1&b=2&c=3&b=4'}
+ d = parse_querystring(e)
+ assert d == [('a', '1'), ('b', '2'), ('c', '3'), ('b', '4')]
+ assert e['paste.parsed_querystring'] == (
+ (d, e['QUERY_STRING']))
+ e = {'QUERY_STRING': 'a&b&c=&d=1'}
+ d = parse_querystring(e)
+ assert d == [('a', ''), ('b', ''), ('c', ''), ('d', '1')]
+
+def make_post(body):
+ e = {
+ 'CONTENT_TYPE': 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH': str(len(body)),
+ 'REQUEST_METHOD': 'POST',
+ 'wsgi.input': six.BytesIO(body),
+ }
+ return e
+
+def test_parsevars():
+ e = make_post(b'a=1&b=2&c=3&b=4')
+ #cur_input = e['wsgi.input']
+ d = parse_formvars(e)
+ assert isinstance(d, MultiDict)
+ assert d == MultiDict([('a', '1'), ('b', '2'), ('c', '3'), ('b', '4')])
+ assert e['paste.parsed_formvars'] == (
+ (d, e['wsgi.input']))
+ # XXX: http://trac.pythonpaste.org/pythonpaste/ticket/125
+ #assert e['wsgi.input'] is not cur_input
+ #cur_input.seek(0)
+ #assert e['wsgi.input'].read() == cur_input.read()