summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey B Kirpichev <skirpichev@gmail.com>2024-07-15 19:21:49 (GMT)
committerGitHub <noreply@github.com>2024-07-15 19:21:49 (GMT)
commitfd085a411ed2ccc9bde2338cf50068bc7f213ece (patch)
tree68356c294f12722ad1b978e3d742a94050c78ed1
parente904300882055bed71cae59f8ca9161066659b7c (diff)
downloadcpython-fd085a411ed2ccc9bde2338cf50068bc7f213ece.zip
cpython-fd085a411ed2ccc9bde2338cf50068bc7f213ece.tar.gz
cpython-fd085a411ed2ccc9bde2338cf50068bc7f213ece.tar.bz2
gh-121359: make clean environment (no PYTHON* vars) for test_pyrepl.TestMain (GH-121672)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
-rw-r--r--Lib/test/test_pyrepl/test_pyrepl.py13
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__'"