mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 11:16:24 +00:00
Port test_create.py to Python 3.
This commit is contained in:
parent
ee99c610b3
commit
7c2a0685bb
@ -1,3 +1,15 @@
|
|||||||
|
"""
|
||||||
|
Ported to Python 3.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from future.utils import PY2
|
||||||
|
if PY2:
|
||||||
|
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import mock
|
import mock
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
|
@ -20,7 +20,7 @@ from twisted.trial import unittest
|
|||||||
|
|
||||||
from ..util.assertutil import precondition
|
from ..util.assertutil import precondition
|
||||||
from ..scripts import runner
|
from ..scripts import runner
|
||||||
from allmydata.util.encodingutil import unicode_platform, get_filesystem_encoding, get_io_encoding, argv_type
|
from allmydata.util.encodingutil import unicode_platform, get_filesystem_encoding, get_io_encoding, argv_type, unicode_to_argv
|
||||||
|
|
||||||
|
|
||||||
def skip_if_cannot_represent_filename(u):
|
def skip_if_cannot_represent_filename(u):
|
||||||
@ -49,6 +49,13 @@ def _getvalue(io):
|
|||||||
return io.read()
|
return io.read()
|
||||||
|
|
||||||
|
|
||||||
|
def maybe_unicode_to_argv(o):
|
||||||
|
"""Convert object to argv form if necessary."""
|
||||||
|
if isinstance(o, unicode):
|
||||||
|
return unicode_to_argv(o)
|
||||||
|
return o
|
||||||
|
|
||||||
|
|
||||||
def run_cli_native(verb, *args, **kwargs):
|
def run_cli_native(verb, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Run a Tahoe-LAFS CLI command specified as bytes (on Python 2) or Unicode
|
Run a Tahoe-LAFS CLI command specified as bytes (on Python 2) or Unicode
|
||||||
@ -74,6 +81,9 @@ def run_cli_native(verb, *args, **kwargs):
|
|||||||
"""
|
"""
|
||||||
nodeargs = kwargs.pop("nodeargs", [])
|
nodeargs = kwargs.pop("nodeargs", [])
|
||||||
encoding = kwargs.pop("encoding", None)
|
encoding = kwargs.pop("encoding", None)
|
||||||
|
verb = maybe_unicode_to_argv(verb)
|
||||||
|
args = [maybe_unicode_to_argv(a) for a in args]
|
||||||
|
nodeargs = [maybe_unicode_to_argv(a) for a in nodeargs]
|
||||||
precondition(
|
precondition(
|
||||||
all(isinstance(arg, argv_type) for arg in [verb] + nodeargs + list(args)),
|
all(isinstance(arg, argv_type) for arg in [verb] + nodeargs + list(args)),
|
||||||
"arguments to run_cli must be {argv_type} -- convert using unicode_to_argv".format(argv_type=argv_type),
|
"arguments to run_cli must be {argv_type} -- convert using unicode_to_argv".format(argv_type=argv_type),
|
||||||
|
@ -138,6 +138,8 @@ PORTED_MODULES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
PORTED_TEST_MODULES = [
|
PORTED_TEST_MODULES = [
|
||||||
|
"allmydata.test.cli.test_create",
|
||||||
|
|
||||||
"allmydata.test.mutable.test_checker",
|
"allmydata.test.mutable.test_checker",
|
||||||
"allmydata.test.mutable.test_datahandle",
|
"allmydata.test.mutable.test_datahandle",
|
||||||
"allmydata.test.mutable.test_different_encoding",
|
"allmydata.test.mutable.test_different_encoding",
|
||||||
|
Loading…
Reference in New Issue
Block a user