GH-100192: fix `asyncio` subprocess tests to pass env vars to subprocess (#100569)

This commit is contained in:
Kumar Aditya 2022-12-28 11:16:04 +05:30 committed by GitHub
parent b95b1b3b25
commit 6835184a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -698,7 +698,8 @@ class SubprocessMixin:
def test_create_subprocess_env_shell(self) -> None:
async def main() -> None:
cmd = f'''{sys.executable} -c "import os, sys; sys.stdout.write(os.getenv('FOO'))"'''
env = {"FOO": 'bar'}
env = os.environ.copy()
env["FOO"] = "bar"
proc = await asyncio.create_subprocess_shell(
cmd, env=env, stdout=subprocess.PIPE
)
@ -710,7 +711,8 @@ class SubprocessMixin:
async def main() -> None:
cmd = [sys.executable, "-c",
"import os, sys; sys.stdout.write(os.getenv('FOO'))"]
env = {"FOO": 'baz'}
env = os.environ.copy()
env["FOO"] = "baz"
proc = await asyncio.create_subprocess_exec(
*cmd, env=env, stdout=subprocess.PIPE
)