More passing tests on Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-01-27 12:45:36 -05:00
parent 4f56ce436a
commit 175a3ca4bb
2 changed files with 8 additions and 6 deletions

View File

@ -2363,7 +2363,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_POST_NEWDIRURL_bad_format(self):
url = (self.webish_url + self.public_url +
"/foo/newdir?t=mkdir&format=foo")
yield self.assertHTTPError(url, 400, "Unknown format: foo",
yield self.assertHTTPError(url, 400, "Unknown format:",
method="post", data="")
def test_POST_NEWDIRURL_emptyname(self):
@ -3121,7 +3121,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_POST_FILEURL_check(self):
bar_url = self.public_url + "/foo/bar.txt"
res = yield self.POST(bar_url, t="check")
self.failUnlessIn("Healthy :", res)
self.failUnlessIn(b"Healthy :", res)
redir_url = "http://allmydata.org/TARGET"
body, headers = self.build_form(t="check", when_done=redir_url)
@ -3130,6 +3130,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
code=http.FOUND)
res = yield self.POST(bar_url, t="check", return_to=redir_url)
res = unicode(res, "utf-8")
self.failUnlessIn("Healthy :", res)
self.failUnlessIn("Return to file", res)
self.failUnlessIn(redir_url, res)
@ -3143,7 +3144,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_POST_FILEURL_check_and_repair(self):
bar_url = self.public_url + "/foo/bar.txt"
res = yield self.POST(bar_url, t="check", repair="true")
self.failUnlessIn("Healthy :", res)
self.failUnlessIn(b"Healthy :", res)
redir_url = "http://allmydata.org/TARGET"
body, headers = self.build_form(t="check", repair="true",
@ -3153,6 +3154,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
code=http.FOUND)
res = yield self.POST(bar_url, t="check", return_to=redir_url)
res = unicode(res, "utf-8")
self.failUnlessIn("Healthy :", res)
self.failUnlessIn("Return to file", res)
self.failUnlessIn(redir_url, res)
@ -3214,9 +3216,9 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
quux_url = "/uri/%s" % urlquote(self._quux_txt_uri)
d = self.POST(quux_url, t="check", repair="true")
def _check(res):
self.failUnlessIn("Healthy", res)
self.failUnlessIn(b"Healthy", res)
d.addCallback(_check)
quux_extension_url = "/uri/%s" % urlquote("%s:3:131073" % self._quux_txt_uri)
quux_extension_url = "/uri/%s" % urlquote("%s:3:131073" % unicode(self._quux_txt_uri, "ascii"))
d.addCallback(lambda ignored:
self.POST(quux_extension_url, t="check", repair="true"))
d.addCallback(_check)

View File

@ -309,7 +309,7 @@ class FileNodeHandler(Resource, ReplaceMeMixin, object):
assert self.parentnode and self.name
d = self.replace_me_with_a_formpost(req, self.client, replace)
else:
raise WebError("POST to file: bad t=%s" % t)
raise WebError("POST to file: bad t=%s" % unicode(t, "ascii"))
return handle_when_done(req, d)