]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-121359: make clean environment (no PYTHON* vars) for test_pyrepl.TestMain...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 15 Jul 2024 20:32:28 +0000 (22:32 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jul 2024 20:32:28 +0000 (22:32 +0200)
(cherry picked from commit fd085a411ed2ccc9bde2338cf50068bc7f213ece)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Lib/test/test_pyrepl/test_pyrepl.py

index 8fff372da97a6ad1324fafc731e2c0439f0b4070..543a13e0e697a80c5999aa036a7323199e8f9181 100644 (file)
@@ -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__'"