Another test passing on Python 3.
This commit is contained in:
parent
8493d70cab
commit
5a2339ced3
|
@ -212,7 +212,7 @@ class FakeDisplayableServer(StubServer): # type: ignore # tahoe-lafs/ticket/35
|
||||||
"application-version": "1.0"
|
"application-version": "1.0"
|
||||||
}
|
}
|
||||||
def get_permutation_seed(self):
|
def get_permutation_seed(self):
|
||||||
return ""
|
return b""
|
||||||
def get_announcement(self):
|
def get_announcement(self):
|
||||||
return self.announcement
|
return self.announcement
|
||||||
def get_nickname(self):
|
def get_nickname(self):
|
||||||
|
@ -579,15 +579,14 @@ class WebMixin(TimezoneMixin):
|
||||||
if isinstance(value, tuple):
|
if isinstance(value, tuple):
|
||||||
filename, value = value
|
filename, value = value
|
||||||
form.append('Content-Disposition: form-data; name="%s"; '
|
form.append('Content-Disposition: form-data; name="%s"; '
|
||||||
'filename="%s"' % (name, filename.encode("utf-8")))
|
'filename="%s"' % (name, filename))
|
||||||
else:
|
else:
|
||||||
form.append('Content-Disposition: form-data; name="%s"' % name)
|
form.append('Content-Disposition: form-data; name="%s"' % name)
|
||||||
form.append('')
|
form.append('')
|
||||||
if isinstance(value, unicode):
|
if isinstance(value, bytes):
|
||||||
value = value.encode("utf-8")
|
value = unicode(value, "utf-8")
|
||||||
else:
|
if not isinstance(value, unicode):
|
||||||
value = str(value)
|
value = unicode(value)
|
||||||
assert isinstance(value, str)
|
|
||||||
form.append(value)
|
form.append(value)
|
||||||
form.append(sep)
|
form.append(sep)
|
||||||
form[-1] += "--"
|
form[-1] += "--"
|
||||||
|
@ -596,7 +595,7 @@ class WebMixin(TimezoneMixin):
|
||||||
if fields:
|
if fields:
|
||||||
body = "\r\n".join(form) + "\r\n"
|
body = "\r\n".join(form) + "\r\n"
|
||||||
headers["content-type"] = "multipart/form-data; boundary=%s" % sepbase
|
headers["content-type"] = "multipart/form-data; boundary=%s" % sepbase
|
||||||
return (body, headers)
|
return (body.encode("utf-8"), headers)
|
||||||
|
|
||||||
def POST(self, urlpath, **fields):
|
def POST(self, urlpath, **fields):
|
||||||
body, headers = self.build_form(**fields)
|
body, headers = self.build_form(**fields)
|
||||||
|
@ -3156,7 +3155,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
def test_POST_DIRURL_check(self):
|
def test_POST_DIRURL_check(self):
|
||||||
foo_url = self.public_url + "/foo"
|
foo_url = self.public_url + "/foo"
|
||||||
res = yield self.POST(foo_url, t="check")
|
res = yield self.POST(foo_url, t="check")
|
||||||
self.failUnlessIn("Healthy :", res)
|
self.failUnlessIn(b"Healthy :", res)
|
||||||
|
|
||||||
redir_url = "http://allmydata.org/TARGET"
|
redir_url = "http://allmydata.org/TARGET"
|
||||||
body, headers = self.build_form(t="check", when_done=redir_url)
|
body, headers = self.build_form(t="check", when_done=redir_url)
|
||||||
|
@ -3165,6 +3164,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
|
||||||
code=http.FOUND)
|
code=http.FOUND)
|
||||||
|
|
||||||
res = yield self.POST(foo_url, t="check", return_to=redir_url)
|
res = yield self.POST(foo_url, t="check", return_to=redir_url)
|
||||||
|
res = unicode(res, "utf-8")
|
||||||
self.failUnlessIn("Healthy :", res)
|
self.failUnlessIn("Healthy :", res)
|
||||||
self.failUnlessIn("Return to file/directory", res)
|
self.failUnlessIn("Return to file/directory", res)
|
||||||
self.failUnlessIn(redir_url, res)
|
self.failUnlessIn(redir_url, res)
|
||||||
|
|
|
@ -40,8 +40,12 @@ def get_arg(req, argname, default=None, multiple=False):
|
||||||
results = []
|
results = []
|
||||||
if argname in req.args:
|
if argname in req.args:
|
||||||
results.extend(req.args[argname])
|
results.extend(req.args[argname])
|
||||||
if req.fields and argname in req.fields:
|
argname_unicode = unicode(argname, "utf-8")
|
||||||
results.append(req.fields[argname].value)
|
if req.fields and argname_unicode in req.fields:
|
||||||
|
value = req.fields[argname_unicode].value
|
||||||
|
if isinstance(value, unicode):
|
||||||
|
value = value.encode("utf-8")
|
||||||
|
results.append(value)
|
||||||
if multiple:
|
if multiple:
|
||||||
return tuple(results)
|
return tuple(results)
|
||||||
if results:
|
if results:
|
||||||
|
|
Loading…
Reference in New Issue