aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>2025-01-21 18:10:08 +0200
committerGitHub <noreply@github.com>2025-01-21 16:10:08 +0000
commit05d12eecbde1ace39826320cadf8e673d709b229 (patch)
tree2e767c71374e498d1f9759e2ba60177152b396d0 /Lib/test/support/__init__.py
parent13475e0a5a317fa61f302f030b0effcb021873d6 (diff)
downloadcpython-05d12eecbde1ace39826320cadf8e673d709b229.tar.gz
cpython-05d12eecbde1ace39826320cadf8e673d709b229.zip
gh-127873: Only check `sys.flags.ignore_environment` for `PYTHON*` env vars (#127877)
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 084b2411e79..89f2a6b916b 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -61,6 +61,7 @@ __all__ = [
"without_optimizer",
"force_not_colorized",
"force_not_colorized_test_class",
+ "make_clean_env",
"BrokenIter",
"in_systemd_nspawn_sync_suppressed",
"run_no_yield_async_fn", "run_yielding_async_fn", "async_yield",
@@ -2871,6 +2872,16 @@ def force_not_colorized_test_class(cls):
return cls
+def make_clean_env() -> dict[str, str]:
+ clean_env = os.environ.copy()
+ for k in clean_env.copy():
+ if k.startswith("PYTHON"):
+ clean_env.pop(k)
+ clean_env.pop("FORCE_COLOR", None)
+ clean_env.pop("NO_COLOR", None)
+ return clean_env
+
+
def initialized_with_pyrepl():
"""Detect whether PyREPL was used during Python initialization."""
# If the main module has a __file__ attribute it's a Python module, which means PyREPL.