diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-07-15 20:32:28 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-15 20:32:28 (GMT) |
| commit | 2ee2bfe617f6912eeb84ee9e45996bba2450f757 (patch) | |
| tree | 66eb777cea011e95b46d1e28debca61b8ae88c75 /Lib/test/test_pyrepl/test_pyrepl.py | |
| parent | 835f4add6095ec76019daf755fa4b80e75a4b0ad (diff) | |
| download | cpython-2ee2bfe617f6912eeb84ee9e45996bba2450f757.zip cpython-2ee2bfe617f6912eeb84ee9e45996bba2450f757.tar.gz cpython-2ee2bfe617f6912eeb84ee9e45996bba2450f757.tar.bz2 | |
[3.13] gh-121359: make clean environment (no PYTHON* vars) for test_pyrepl.TestMain (GH-121672) (GH-121810)
(cherry picked from commit fd085a411ed2ccc9bde2338cf50068bc7f213ece)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
| -rw-r--r-- | Lib/test/test_pyrepl/test_pyrepl.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 8fff372..543a13e 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -884,6 +884,19 @@ class TestPasteEvent(TestCase): @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__'" |
