diff options
-rwxr-xr-x | paste/debug/debugapp.py | 12 | ||||
-rw-r--r-- | paste/fixture.py | 17 | ||||
-rw-r--r-- | tests/test_fixture.py | 11 |
3 files changed, 29 insertions, 11 deletions
diff --git a/paste/debug/debugapp.py b/paste/debug/debugapp.py index f752c36..ca5730e 100755 --- a/paste/debug/debugapp.py +++ b/paste/debug/debugapp.py @@ -54,14 +54,14 @@ class SlowConsumer(object): time.sleep(self.delay) body = "<html><body>%d bytes</body></html>" % size else: - body = ('<html><body>\n' - '<form method="post" enctype="multipart/form-data">\n' - '<input type="file" name="file">\n' - '<input type="submit" >\n' - '</form></body></html>\n') + body = (b'<html><body>\n' + b'<form method="post" enctype="multipart/form-data">\n' + b'<input type="file" name="file">\n' + b'<input type="submit" >\n' + b'</form></body></html>\n') print("bingles") start_response("200 OK", [('Content-Type', 'text/html'), - ('Content-Length', len(body))]) + ('Content-Length', str(len(body)))]) return [body] def make_test_app(global_conf): diff --git a/paste/fixture.py b/paste/fixture.py index cedf9a8..b10a706 100644 --- a/paste/fixture.py +++ b/paste/fixture.py @@ -557,7 +557,10 @@ class TestResponse(object): forms = self._forms_indexed = {} form_texts = [] started = None - for match in self._tag_re.finditer(self.body): + body = self.body + if not six.PY2: + body = body.decode('utf8', 'xmlcharrefreplace') + for match in self._tag_re.finditer(body): end = match.group(1) == '/' tag = match.group(2).lower() if tag != 'form': @@ -961,8 +964,11 @@ class Form(object): in_select = None in_textarea = None fields = {} - for match in self._tag_re.finditer(self.text): - end = match.group(1) == '/' + text = self.text + if not six.PY2: + text = text.decode('utf8', 'xmlcharrefreplace') + for match in self._tag_re.finditer(text): + end = match.group(1) == b'/' tag = match.group(2).lower() if tag not in ('input', 'select', 'option', 'textarea', 'button'): @@ -1020,7 +1026,10 @@ class Form(object): def _parse_action(self): self.action = None - for match in self._tag_re.finditer(self.text): + text = self.text + if not six.PY2: + text = text.decode('utf8', 'xmlcharrefreplace') + for match in self._tag_re.finditer(text): end = match.group(1) == '/' tag = match.group(2).lower() if tag != 'form': diff --git a/tests/test_fixture.py b/tests/test_fixture.py index ba56488..f5a659a 100644 --- a/tests/test_fixture.py +++ b/tests/test_fixture.py @@ -1,6 +1,7 @@ -from paste.debug.debugapp import SimpleApplication +from paste.debug.debugapp import SimpleApplication, SlowConsumer from paste.fixture import TestApp + def test_fixture(): app = TestApp(SimpleApplication()) res = app.get('/', params={'a': ['1', '2']}) @@ -26,3 +27,11 @@ def test_fixture(): assert ('one=first' in hc) assert ('two=second' in hc) assert ('three=' in hc) + + +def test_fixture_form(): + app = TestApp(SlowConsumer()) + res = app.get('/') + form = res.forms[0] + assert 'file' in form.fields + assert form.action == '' |