diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-11-03 11:38:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-03 11:38:40 +0100 |
commit | 009fddc96b88a9aee1232d6a2637f2970fdcfb50 (patch) | |
tree | 3f1e573b9311a3ecd71d6d073c1dddc59e62a6b2 /tests/dbshell | |
parent | 542b4b3ab44d33dfd9b00c22f624ee4aed6f7534 (diff) | |
download | django-009fddc96b88a9aee1232d6a2637f2970fdcfb50.tar.gz |
Refs #32061 -- Fixed test_crash_password_does_not_leak() crash on Windows.
When env is passed to subprocess.run() we should pass all existing
environment variables. This fixes crash on Windows:
Fatal Python error: failed to get random numbers to initialize Python
Fatal Python error: _Py_HashRandomization_Init: failed to get random
numbers to initialize Python
Python runtime state: preinitialized
Diffstat (limited to 'tests/dbshell')
-rw-r--r-- | tests/dbshell/test_mysql.py | 3 | ||||
-rw-r--r-- | tests/dbshell/test_postgresql.py | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/tests/dbshell/test_mysql.py b/tests/dbshell/test_mysql.py index b002a5d274..c3ecc6503b 100644 --- a/tests/dbshell/test_mysql.py +++ b/tests/dbshell/test_mysql.py @@ -1,3 +1,4 @@ +import os import subprocess import sys from pathlib import Path @@ -190,6 +191,8 @@ class MySqlDbshellCommandTestCase(SimpleTestCase): }, [], ) + if env: + env = {**os.environ, **env} fake_client = Path(__file__).with_name('fake_client.py') args[0:1] = [sys.executable, str(fake_client)] with self.assertRaises(subprocess.CalledProcessError) as ctx: diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py index 4d8804e43e..ccf49d7e50 100644 --- a/tests/dbshell/test_postgresql.py +++ b/tests/dbshell/test_postgresql.py @@ -1,3 +1,4 @@ +import os import signal import subprocess import sys @@ -121,6 +122,8 @@ class PostgreSqlDbshellCommandTestCase(SimpleTestCase): # The password doesn't leak in an exception that results from a client # crash. args, env = self.settings_to_cmd_args_env({'PASSWORD': 'somepassword'}, []) + if env: + env = {**os.environ, **env} fake_client = Path(__file__).with_name('fake_client.py') args[0:1] = [sys.executable, str(fake_client)] with self.assertRaises(subprocess.CalledProcessError) as ctx: |