From 3eb62f1d0f3809881bf7b0ad693ca4fc6ebd30bd Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 25 Jan 2021 09:25:20 -0500 Subject: [PATCH] More passing tests on Python 3. --- src/allmydata/test/web/test_web.py | 16 ++++++++-------- src/allmydata/web/info.py | 11 ++++++----- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/allmydata/test/web/test_web.py b/src/allmydata/test/web/test_web.py index 0437cdfe8..4908ab0d7 100644 --- a/src/allmydata/test/web/test_web.py +++ b/src/allmydata/test/web/test_web.py @@ -1644,35 +1644,35 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi return d def test_GET_FILEURL_info_mdmf(self): - d = self.GET("/uri/%s?t=info" % self._quux_txt_uri) + d = self.GET("/uri/%s?t=info" % unicode(self._quux_txt_uri, "ascii")) def _got(res): - self.failUnlessIn("mutable file (mdmf)", res) + self.failUnlessIn(b"mutable file (mdmf)", res) self.failUnlessIn(self._quux_txt_uri, res) self.failUnlessIn(self._quux_txt_readonly_uri, res) d.addCallback(_got) return d def test_GET_FILEURL_info_mdmf_readonly(self): - d = self.GET("/uri/%s?t=info" % self._quux_txt_readonly_uri) + d = self.GET("/uri/%s?t=info" % unicode(self._quux_txt_readonly_uri, "ascii")) def _got(res): - self.failUnlessIn("mutable file (mdmf)", res) + self.failUnlessIn(b"mutable file (mdmf)", res) self.failIfIn(self._quux_txt_uri, res) self.failUnlessIn(self._quux_txt_readonly_uri, res) d.addCallback(_got) return d def test_GET_FILEURL_info_sdmf(self): - d = self.GET("/uri/%s?t=info" % self._baz_txt_uri) + d = self.GET("/uri/%s?t=info" % unicode(self._baz_txt_uri, "ascii")) def _got(res): - self.failUnlessIn("mutable file (sdmf)", res) + self.failUnlessIn(b"mutable file (sdmf)", res) self.failUnlessIn(self._baz_txt_uri, res) d.addCallback(_got) return d def test_GET_FILEURL_info_mdmf_extensions(self): - d = self.GET("/uri/%s:STUFF?t=info" % self._quux_txt_uri) + d = self.GET("/uri/%s:STUFF?t=info" % unicode(self._quux_txt_uri, "ascii")) def _got(res): - self.failUnlessIn("mutable file (mdmf)", res) + self.failUnlessIn(b"mutable file (mdmf)", res) self.failUnlessIn(self._quux_txt_uri, res) self.failUnlessIn(self._quux_txt_readonly_uri, res) d.addCallback(_got) diff --git a/src/allmydata/web/info.py b/src/allmydata/web/info.py index 7eccfea9e..e6bca0e04 100644 --- a/src/allmydata/web/info.py +++ b/src/allmydata/web/info.py @@ -1,5 +1,6 @@ -import os, urllib +import os +from urllib.parse import quote as urlquote from twisted.python.filepath import FilePath from twisted.web.template import tags as T, Element, renderElement, XMLFile, renderer @@ -180,7 +181,7 @@ class MoreInfoElement(Element): else: return "" root = self.get_root(req) - quoted_uri = urllib.quote(node.get_uri()) + quoted_uri = urlquote(node.get_uri()) text_plain_url = "%s/file/%s/@@named=/raw.txt" % (root, quoted_uri) return T.li("Raw data as ", T.a("text/plain", href=text_plain_url)) @@ -196,7 +197,7 @@ class MoreInfoElement(Element): @renderer def check_form(self, req, tag): node = self.original - quoted_uri = urllib.quote(node.get_uri()) + quoted_uri = urlquote(node.get_uri()) target = self.get_root(req) + "/uri/" + quoted_uri if IDirectoryNode.providedBy(node): target += "/" @@ -236,8 +237,8 @@ class MoreInfoElement(Element): def overwrite_form(self, req, tag): node = self.original root = self.get_root(req) - action = "%s/uri/%s" % (root, urllib.quote(node.get_uri())) - done_url = "%s/uri/%s?t=info" % (root, urllib.quote(node.get_uri())) + action = "%s/uri/%s" % (root, urlquote(node.get_uri())) + done_url = "%s/uri/%s?t=info" % (root, urlquote(node.get_uri())) overwrite = T.form(action=action, method="post", enctype="multipart/form-data")( T.fieldset(