https://github.com/python/cpython/commit/fd085a411ed2ccc9bde2338cf50068bc7f213ece commit: fd085a411ed2ccc9bde2338cf50068bc7f213ece branch: main author: Sergey B Kirpichev <[email protected]> committer: ambv <[email protected]> date: 2024-07-15T21:21:49+02:00 summary:
gh-121359: make clean environment (no PYTHON* vars) for test_pyrepl.TestMain (GH-121672) Co-authored-by: Ćukasz Langa <[email protected]> files: M Lib/test/test_pyrepl/test_pyrepl.py diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 8fff372da97a6a..543a13e0e697a8 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -884,6 +884,19 @@ def test_bracketed_paste_single_line(self): @skipUnless(pty, "requires pty") class TestMain(TestCase): + def setUp(self): + # Cleanup from PYTHON* variables to isolate from local + # user settings, see #121359. Such variables should be + # added later in test methods to patched os.environ. + clean_env = os.environ.copy() + for k in clean_env.copy(): + if k.startswith("PYTHON"): + clean_env.pop(k) + + patcher = patch('os.environ', new=clean_env) + self.addCleanup(patcher.stop) + patcher.start() + @force_not_colorized def test_exposed_globals_in_repl(self): pre = "['__annotations__', '__builtins__'" _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
