Skip to content

Commit 2ee2bfe

Browse files
miss-islingtonskirpichevambv
authored
[3.13] gh-121359: make clean environment (no PYTHON* vars) for test_pyrepl.TestMain (GH-121672) (GH-121810)
(cherry picked from commit fd085a4) Co-authored-by: Sergey B Kirpichev <[email protected]> Co-authored-by: Łukasz Langa <[email protected]>
1 parent 835f4ad commit 2ee2bfe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,19 @@ def test_bracketed_paste_single_line(self):
884884

885885
@skipUnless(pty, "requires pty")
886886
class TestMain(TestCase):
887+
def setUp(self):
888+
# Cleanup from PYTHON* variables to isolate from local
889+
# user settings, see #121359. Such variables should be
890+
# added later in test methods to patched os.environ.
891+
clean_env = os.environ.copy()
892+
for k in clean_env.copy():
893+
if k.startswith("PYTHON"):
894+
clean_env.pop(k)
895+
896+
patcher = patch('os.environ', new=clean_env)
897+
self.addCleanup(patcher.stop)
898+
patcher.start()
899+
887900
@force_not_colorized
888901
def test_exposed_globals_in_repl(self):
889902
pre = "['__annotations__', '__builtins__'"

0 commit comments

Comments
 (0)