More passing tests on Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-01-27 12:39:28 -05:00
parent c1391159fa
commit 4f56ce436a
2 changed files with 11 additions and 11 deletions

View File

@ -2163,7 +2163,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
soup = BeautifulSoup(manifest, 'html5lib')
assert_soup_has_text(self, soup, "Manifest of SI=")
assert_soup_has_text(self, soup, "sub")
assert_soup_has_text(self, soup, self._sub_uri)
assert_soup_has_text(self, soup, unicode(self._sub_uri, "ascii"))
assert_soup_has_text(self, soup, "sub/baz.txt")
assert_soup_has_favicon(self, soup)
d.addCallback(_got_html)
@ -2176,8 +2176,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
d.addCallback(_got_html)
d.addCallback(getman, "text")
def _got_text(manifest):
self.failUnlessIn("\nsub " + self._sub_uri + "\n", manifest)
self.failUnlessIn("\nsub/baz.txt URI:CHK:", manifest)
self.failUnlessIn(b"\nsub " + self._sub_uri + b"\n", manifest)
self.failUnlessIn(b"\nsub/baz.txt URI:CHK:", manifest)
d.addCallback(_got_text)
d.addCallback(getman, "JSON")
def _got_json(res):
@ -2267,8 +2267,8 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
def test_POST_DIRURL_stream_manifest(self):
d = self.POST(self.public_url + "/foo?t=stream-manifest")
def _check(res):
self.failUnless(res.endswith("\n"))
units = [json.loads(t) for t in res[:-1].split("\n")]
self.failUnless(res.endswith(b"\n"))
units = [json.loads(t) for t in res[:-1].split(b"\n")]
self.failUnlessReallyEqual(len(units), 10)
self.failUnlessEqual(units[-1]["type"], "stats")
first = units[0]

View File

@ -1144,8 +1144,8 @@ def _slashify_path(path):
in it
"""
if not path:
return ""
return "/".join([p.encode("utf-8") for p in path])
return b""
return b"/".join([p.encode("utf-8") for p in path])
def _cap_to_link(root, path, cap):
@ -1234,10 +1234,10 @@ class ManifestResults(MultiFormatResource, ReloadMixin):
req.setHeader("content-type", "text/plain")
lines = []
is_finished = self.monitor.is_finished()
lines.append("finished: " + {True: "yes", False: "no"}[is_finished])
lines.append(b"finished: " + {True: b"yes", False: b"no"}[is_finished])
for path, cap in self.monitor.get_status()["manifest"]:
lines.append(_slashify_path(path) + " " + cap)
return "\n".join(lines) + "\n"
lines.append(_slashify_path(path) + b" " + cap)
return b"\n".join(lines) + b"\n"
def render_JSON(self, req):
req.setHeader("content-type", "text/plain")
@ -1315,7 +1315,7 @@ class DeepStatsResults(Resource, object):
req.setHeader("content-type", "text/plain")
s = self.monitor.get_status().copy()
s["finished"] = self.monitor.is_finished()
return json.dumps(s, indent=1)
return json.dumps(s, indent=1).encode("utf-8")
@implementer(IPushProducer)