Even more progress towards Python 3 tests passing.

This commit is contained in:
Itamar Turner-Trauring 2021-04-22 10:43:55 -04:00
parent 56e4385103
commit b85d735b8b
2 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,9 @@
from __future__ import print_function
from past.builtins import unicode
from six.moves import cStringIO as StringIO
import urllib
from urllib.parse import quote as url_quote
from allmydata.scripts.common_http import do_http, format_http_success, format_http_error
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \
@ -46,19 +48,20 @@ def put(options):
# FIXME: don't hardcode cap format.
if to_file.startswith("URI:MDMF:") or to_file.startswith("URI:SSK:"):
url = nodeurl + "uri/%s" % urllib.quote(to_file)
url = nodeurl + "uri/%s" % url_quote(to_file)
else:
try:
rootcap, path = get_alias(aliases, to_file, DEFAULT_ALIAS)
except UnknownAliasError as e:
e.display(stderr)
return 1
path = unicode(path, "utf-8")
if path.startswith("/"):
suggestion = to_file.replace(u"/", u"", 1)
print("Error: The remote filename must not start with a slash", file=stderr)
print("Please try again, perhaps with %s" % quote_output(suggestion), file=stderr)
return 1
url = nodeurl + "uri/%s/" % urllib.quote(rootcap)
url = nodeurl + "uri/%s/" % url_quote(rootcap)
if path:
url += escape_path(path)
else:

View File

@ -1,5 +1,6 @@
from __future__ import print_function
from future.utils import PY2
from past.builtins import unicode
import os.path, json
@ -64,7 +65,9 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
self.failUnlessIn("files whose names could not be converted", err)
else:
self.failUnlessReallyEqual(rc, 0)
self.failUnlessReallyEqual(out.decode(get_io_encoding()), u"Metallica\n\u00C4rtonwall\n")
if PY2:
out = out.decode(get_io_encoding())
self.failUnlessReallyEqual(out, u"Metallica\n\u00C4rtonwall\n")
self.failUnlessReallyEqual(err, "")
d.addCallback(_check)
@ -220,7 +223,9 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
self.failUnlessIn("files whose names could not be converted", err)
else:
self.failUnlessReallyEqual(rc, 0)
self.failUnlessReallyEqual(out.decode(get_io_encoding()), u"\u00C4rtonwall\n")
if PY2:
out = out.decode(get_io_encoding())
self.failUnlessReallyEqual(out, u"\u00C4rtonwall\n")
self.failUnlessReallyEqual(err, "")
d.addCallback(_check)
@ -259,6 +264,7 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase):
def _get_test_txt_uris(args):
(rc, out, err) = args
self.failUnlessEqual(rc, 0)
import pdb; pdb.set_trace()
filetype, data = json.loads(out)
self.failUnlessEqual(filetype, "filenode")