Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix translation of subprocess.getoutput to be aligned with Py version #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion six.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class _MovedItems(_LazyModule):
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
MovedAttribute("getoutput", "commands", "subprocess"),
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
MovedAttribute("reduce", "__builtin__", "functools"),
Expand Down Expand Up @@ -301,6 +300,9 @@ class _MovedItems(_LazyModule):
MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
]
if not (sys.platform == "win32" and sys.version_info[:3] < (3, 3, 4)):
#support for subprocess.getoutput() on Windows was added for Py>=3.3.4
_moved_attributes.append(MovedAttribute("getoutput", "commands", "subprocess"))
# Add windows specific modules.
if sys.platform == "win32":
_moved_attributes += [
Expand Down
5 changes: 3 additions & 2 deletions test_six.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ def test_map():
from six.moves import map
assert six.advance_iterator(map(lambda x: x + 1, range(2))) == 1


@py.test.mark.skipif("sys.version_info[:3] < (3, 3, 4) and sys.platform.startswith('win')")
def test_getoutput():
from six.moves import getoutput
output = getoutput('echo "foo"')
assert output == 'foo'
#On Unix platforms, foo is returned and on Windows, "foo".
assert output in ['foo', '"foo"']


def test_zip():
Expand Down