Make test_runner and test_windows both use the good Popen

This commit is contained in:
Jean-Paul Calderone 2021-01-11 15:07:37 -05:00
parent 73110f48da
commit c6d108ddb2
3 changed files with 32 additions and 17 deletions

View File

@ -9,6 +9,10 @@ __all__ = [
"flush_logged_errors",
"skip",
"skipIf",
# Selected based on platform and re-exported for convenience.
"Popen",
"PIPE",
]
from past.builtins import chr as byteschr, unicode
@ -48,6 +52,9 @@ from testtools.twistedsupport import (
flush_logged_errors,
)
from twisted.python.runtime import (
platform,
)
from twisted.application import service
from twisted.plugin import IPlugin
from twisted.internet import defer
@ -101,6 +108,21 @@ from .eliotutil import (
)
from .common_util import ShouldFailMixin # noqa: F401
if platform.isWindows():
# Python 2.7 doesn't have good options for launching a process with
# non-ASCII in its command line. So use this alternative that does a
# better job. However, only use it on Windows because it doesn't work
# anywhere else.
from ._win_subprocess import (
PIPE,
Popen,
)
else:
from subprocess import (
PIPE,
Popen,
)
TEST_RSA_KEY_SIZE = 522

View File

@ -5,10 +5,6 @@ from __future__ import (
import os.path, re, sys
from os import linesep
from subprocess import (
PIPE,
Popen,
)
from eliot import (
log_call,
@ -29,7 +25,14 @@ from twisted.python.runtime import (
from allmydata.util import fileutil, pollmixin
from allmydata.test import common_util
import allmydata
from .common_util import parse_cli, run_cli
from .common import (
PIPE,
Popen,
)
from .common_util import (
parse_cli,
run_cli,
)
from .cli_node_api import (
CLINodeAPI,
Expect,

View File

@ -29,11 +29,6 @@ from json import (
from textwrap import (
dedent,
)
from subprocess import (
PIPE,
Popen,
)
from twisted.python.filepath import (
FilePath,
)
@ -66,6 +61,8 @@ from hypothesis.strategies import (
)
from .common import (
PIPE,
Popen,
SyncTestCase,
)
@ -132,13 +129,6 @@ class GetArgvTests(SyncTestCase):
``get_argv`` returns a list representing the result of tokenizing the
"command line" argument string provided to Windows processes.
"""
# Python 2.7 doesn't have good options for launching a process with
# non-ASCII in its command line. So use this alternative that does a
# better job. Bury the import here because it only works on Windows.
from ._win_subprocess import (
Popen
)
working_path = FilePath(self.mktemp())
working_path.makedirs()
save_argv_path = working_path.child("script.py")