Skip to content

Commit

Permalink
Use text mode for subprocess, avoiding unicode sandwich.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 4, 2022
1 parent 03b06ee commit 54b43bd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions setuptools/tests/test_windows_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def test_basic(self, tmpdir):
'arg5 a\\\\b',
]
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
stdout, stderr = proc.communicate('hello\nworld\n'.encode('ascii'))
actual = stdout.decode('ascii').replace('\r\n', '\n')
cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, text=True)
stdout, stderr = proc.communicate('hello\nworld\n')
actual = stdout.replace('\r\n', '\n')
expected = textwrap.dedent(r"""
\foo-script.py
['arg1', 'arg 2', 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b']
Expand Down Expand Up @@ -148,9 +148,11 @@ def test_with_options(self, tmpdir):
cmd,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT)
stderr=subprocess.STDOUT,
text=True,
)
stdout, stderr = proc.communicate()
actual = stdout.decode('ascii').replace('\r\n', '\n')
actual = stdout.replace('\r\n', '\n')
expected = textwrap.dedent(r"""
\foo-script.py
[]
Expand Down Expand Up @@ -188,7 +190,7 @@ def test_basic(self, tmpdir):
]
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
stderr=subprocess.STDOUT)
stderr=subprocess.STDOUT, text=True)
stdout, stderr = proc.communicate()
assert not stdout
assert not stderr
Expand Down

0 comments on commit 54b43bd

Please sign in to comment.