Encoding for subprocess.run
This commit is contained in:
parent
a704605cf1
commit
7e510769b4
|
@ -6,6 +6,7 @@ import collections.abc
|
||||||
import contextlib
|
import contextlib
|
||||||
import gc
|
import gc
|
||||||
import importlib
|
import importlib
|
||||||
|
import locale
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
@ -129,6 +130,7 @@ class LsofFdLeakChecker:
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
check=True,
|
check=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding=locale.getpreferredencoding(False),
|
||||||
).stdout
|
).stdout
|
||||||
|
|
||||||
def isopen(line: str) -> bool:
|
def isopen(line: str) -> bool:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import argparse
|
import argparse
|
||||||
|
import locale
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -289,6 +290,10 @@ class TestParser:
|
||||||
|
|
||||||
|
|
||||||
def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
|
def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
|
||||||
|
try:
|
||||||
|
encoding = locale.getencoding() # New in Python 3.11, ignores utf-8 mode
|
||||||
|
except AttributeError:
|
||||||
|
encoding = locale.getpreferredencoding(False)
|
||||||
try:
|
try:
|
||||||
bash_version = subprocess.run(
|
bash_version = subprocess.run(
|
||||||
["bash", "--version"],
|
["bash", "--version"],
|
||||||
|
@ -296,6 +301,7 @@ def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
check=True,
|
check=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding=encoding,
|
||||||
).stdout
|
).stdout
|
||||||
except (OSError, subprocess.CalledProcessError):
|
except (OSError, subprocess.CalledProcessError):
|
||||||
pytest.skip("bash is not available")
|
pytest.skip("bash is not available")
|
||||||
|
|
Loading…
Reference in New Issue