aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_pyrepl/support.py
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2024-07-17 15:18:42 +0100
committerGitHub <noreply@github.com>2024-07-17 16:18:42 +0200
commitac07451116d52dd6a5545d27b6a2e3737ed27cf0 (patch)
tree6420b13d1aff4436d3c596bd7a16994466fbd6b4 /Lib/test/test_pyrepl/support.py
parent58753f33e47fe48906883dc010771f68c13b7e52 (diff)
downloadcpython-ac07451116d52dd6a5545d27b6a2e3737ed27cf0.tar.gz
cpython-ac07451116d52dd6a5545d27b6a2e3737ed27cf0.zip
gh-120678: pyrepl: Include globals from modules passed with `-i` (GH-120904)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/test/test_pyrepl/support.py')
-rw-r--r--Lib/test/test_pyrepl/support.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_pyrepl/support.py b/Lib/test/test_pyrepl/support.py
index 58b1a92d68b..cb5cb4ab20a 100644
--- a/Lib/test/test_pyrepl/support.py
+++ b/Lib/test/test_pyrepl/support.py
@@ -1,3 +1,4 @@
+import os
from code import InteractiveConsole
from functools import partial
from typing import Iterable
@@ -100,8 +101,18 @@ handle_events_narrow_console = partial(
)
+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
+
+
class FakeConsole(Console):
- def __init__(self, events, encoding="utf-8"):
+ def __init__(self, events, encoding="utf-8") -> None:
self.events = iter(events)
self.encoding = encoding
self.screen = []