From 175a3ca4bbc6166918b3ef93db99c35573f471e2 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Wed, 27 Jan 2021 12:45:36 -0500 Subject: [PATCH] More passing tests on Python 3. --- src/allmydata/test/web/test_web.py | 12 +++++++----- src/allmydata/web/filenode.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/allmydata/test/web/test_web.py b/src/allmydata/test/web/test_web.py index 4996d841e..8dc22a4e1 100644 --- a/src/allmydata/test/web/test_web.py +++ b/src/allmydata/test/web/test_web.py @@ -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) diff --git a/src/allmydata/web/filenode.py b/src/allmydata/web/filenode.py index 4efc5d63a..d050fb8a0 100644 --- a/src/allmydata/web/filenode.py +++ b/src/allmydata/web/filenode.py @@ -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)