mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-01 00:45:52 +00:00
Some progress towards test_system.py fully running on Python 3.
This commit is contained in:
parent
7411da1b88
commit
cc176342d4
@ -1,6 +1,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
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, \
|
||||
UnknownAliasError
|
||||
@ -27,7 +27,7 @@ def unlink(options, command="unlink"):
|
||||
'tahoe %s' can only unlink directory entries, so a path must be given.""" % (command,), file=stderr)
|
||||
return 1
|
||||
|
||||
url = nodeurl + "uri/%s" % urllib.quote(rootcap)
|
||||
url = nodeurl + "uri/%s" % url_quote(rootcap)
|
||||
url += "/" + escape_path(path)
|
||||
|
||||
resp = do_http("DELETE", url)
|
||||
|
@ -85,7 +85,7 @@ def run_cli_native(verb, *args, **kwargs):
|
||||
bytes.
|
||||
"""
|
||||
nodeargs = kwargs.pop("nodeargs", [])
|
||||
encoding = kwargs.pop("encoding", "utf-8")
|
||||
encoding = kwargs.pop("encoding", None) or "utf-8"
|
||||
return_bytes = kwargs.pop("return_bytes", False)
|
||||
verb = maybe_unicode_to_argv(verb)
|
||||
args = [maybe_unicode_to_argv(a) for a in args]
|
||||
|
@ -1,12 +1,12 @@
|
||||
"""
|
||||
Ported to Python 3, partially: test_filesystem* will be done in a future round.
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2, PY3
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
# Don't import bytes since it causes issues on (so far unported) modules on Python 2.
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, dict, list, object, range, max, min, str # noqa: F401
|
||||
@ -16,7 +16,6 @@ from six import ensure_text, ensure_str
|
||||
|
||||
import os, re, sys, time, json
|
||||
from functools import partial
|
||||
from unittest import skipIf
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
@ -1665,8 +1664,6 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
d.addCallback(self.log, "did _check_publish_private")
|
||||
d.addCallback(self._test_web)
|
||||
d.addCallback(self._test_control)
|
||||
if PY2:
|
||||
# TODO when CLI is ported to Python 3, reenable.
|
||||
d.addCallback(self._test_cli)
|
||||
# P now has four top-level children:
|
||||
# P/personal/sekrit data
|
||||
@ -2298,7 +2295,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
def _check_aliases_1(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
self.failUnlessEqual(out.strip(" \n"), "tahoe: %s" % private_uri)
|
||||
self.failUnlessEqual(out.strip(" \n"), "tahoe: %s" % str(private_uri, "ascii"))
|
||||
d.addCallback(_check_aliases_1)
|
||||
|
||||
# now that that's out of the way, remove root_dir.cap and work with
|
||||
@ -2355,7 +2352,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
(out, err) = out_and_err
|
||||
self.failUnlessEqual(err, "")
|
||||
if filenum is not None:
|
||||
self.failUnlessEqual(out, datas[filenum])
|
||||
self.failUnlessEqual(out, str(datas[filenum], "ascii"))
|
||||
if data is not None:
|
||||
self.failUnlessEqual(out, data)
|
||||
|
||||
@ -2369,7 +2366,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
uri0 = out.strip()
|
||||
return run(None, "get", uri0)
|
||||
d.addCallback(_put_out)
|
||||
d.addCallback(lambda out_err: self.failUnlessEqual(out_err[0], datas[0]))
|
||||
d.addCallback(lambda out_err: self.failUnlessEqual(out_err[0], str(datas[0], "ascii")))
|
||||
|
||||
d.addCallback(run, "put", files[1], "subdir/tahoe-file1")
|
||||
# tahoe put bar tahoe:FOO
|
||||
@ -2411,14 +2408,14 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
def _check_outfile0(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
data = open(outfile0,"rb").read()
|
||||
self.failUnlessEqual(data, "data to be uploaded: file2\n")
|
||||
self.failUnlessEqual(data, b"data to be uploaded: file2\n")
|
||||
d.addCallback(_check_outfile0)
|
||||
outfile1 = os.path.join(self.basedir, "outfile0")
|
||||
d.addCallback(run, "get", "tahoe:subdir/tahoe-file1", outfile1)
|
||||
def _check_outfile1(out_and_err):
|
||||
(out, err) = out_and_err
|
||||
data = open(outfile1,"rb").read()
|
||||
self.failUnlessEqual(data, "data to be uploaded: file1\n")
|
||||
self.failUnlessEqual(data, b"data to be uploaded: file1\n")
|
||||
d.addCallback(_check_outfile1)
|
||||
|
||||
d.addCallback(run, "unlink", "tahoe-file0")
|
||||
@ -2455,7 +2452,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
if "file3" in l:
|
||||
rw_uri = self._mutable_file3_uri
|
||||
u = uri.from_string_mutable_filenode(rw_uri)
|
||||
ro_uri = u.get_readonly().to_string()
|
||||
ro_uri = str(u.get_readonly().to_string(), "ascii")
|
||||
self.failUnless(ro_uri in l)
|
||||
d.addCallback(_check_ls_rouri)
|
||||
|
||||
@ -2528,17 +2525,17 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
dn = os.path.join(self.basedir, "dir1")
|
||||
os.makedirs(dn)
|
||||
with open(os.path.join(dn, "rfile1"), "wb") as f:
|
||||
f.write("rfile1")
|
||||
f.write(b"rfile1")
|
||||
with open(os.path.join(dn, "rfile2"), "wb") as f:
|
||||
f.write("rfile2")
|
||||
f.write(b"rfile2")
|
||||
with open(os.path.join(dn, "rfile3"), "wb") as f:
|
||||
f.write("rfile3")
|
||||
f.write(b"rfile3")
|
||||
sdn2 = os.path.join(dn, "subdir2")
|
||||
os.makedirs(sdn2)
|
||||
with open(os.path.join(sdn2, "rfile4"), "wb") as f:
|
||||
f.write("rfile4")
|
||||
f.write(b"rfile4")
|
||||
with open(os.path.join(sdn2, "rfile5"), "wb") as f:
|
||||
f.write("rfile5")
|
||||
f.write(b"rfile5")
|
||||
|
||||
# from disk into tahoe
|
||||
d.addCallback(run, "cp", "-r", dn, "tahoe:")
|
||||
@ -2615,7 +2612,6 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
|
||||
return d
|
||||
|
||||
@skipIf(PY3, "Python 3 CLI support hasn't happened yet.")
|
||||
def test_filesystem_with_cli_in_subprocess(self):
|
||||
# We do this in a separate test so that test_filesystem doesn't skip if we can't run bin/tahoe.
|
||||
|
||||
@ -2659,9 +2655,9 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
||||
def _check_ls(res):
|
||||
out, err, rc_or_sig = res
|
||||
self.failUnlessEqual(rc_or_sig, 0, str(res))
|
||||
self.failUnlessEqual(err, "", str(res))
|
||||
self.failUnlessIn("tahoe-moved", out)
|
||||
self.failIfIn("tahoe-file", out)
|
||||
self.failUnlessEqual(err, b"", str(res))
|
||||
self.failUnlessIn(b"tahoe-moved", out)
|
||||
self.failIfIn(b"tahoe-file", out)
|
||||
d.addCallback(_check_ls)
|
||||
return d
|
||||
|
||||
|
@ -260,12 +260,7 @@ PORTED_TEST_MODULES = [
|
||||
"allmydata.test.test_storage",
|
||||
"allmydata.test.test_storage_client",
|
||||
"allmydata.test.test_storage_web",
|
||||
|
||||
# Only partially ported, test_filesystem_with_cli_in_subprocess isn't
|
||||
# ported yet, nor is part of test_filesystem (the call to _test_cli). This
|
||||
# should be done once CLI is ported.
|
||||
"allmydata.test.test_system",
|
||||
|
||||
"allmydata.test.test_testing",
|
||||
"allmydata.test.test_time_format",
|
||||
"allmydata.test.test_tor_provider",
|
||||
|
Loading…
x
Reference in New Issue
Block a user