diff options
author | devdanzin <74280297+devdanzin@users.noreply.github.com> | 2024-06-26 10:39:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-26 10:39:07 (GMT) |
commit | 9e45fd9858a059950f7387b4fda2b00df0e8e537 (patch) | |
tree | d517eef138d6aba199ecca6423e34c4ab25ef52a /Lib/test/test_pyrepl/test_pyrepl.py | |
parent | ef28f6df42c916b058ed14275fb1ceba63ede28e (diff) | |
download | cpython-9e45fd9858a059950f7387b4fda2b00df0e8e537.zip cpython-9e45fd9858a059950f7387b4fda2b00df0e8e537.tar.gz cpython-9e45fd9858a059950f7387b4fda2b00df0e8e537.tar.bz2 |
gh-121016: Add test for `PYTHON_BASIC_REPL` envioronment variable (#121017)
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r-- | Lib/test/test_pyrepl/test_pyrepl.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index adc55f2..21a570d 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -862,6 +862,31 @@ class TestMain(TestCase): self.assertNotIn("Exception", output) self.assertNotIn("Traceback", output) + @force_not_colorized + def test_python_basic_repl(self): + env = os.environ.copy() + commands = ("from test.support import initialized_with_pyrepl\n" + "initialized_with_pyrepl()\n" + "exit()\n") + + env.pop("PYTHON_BASIC_REPL", None) + output, exit_code = self.run_repl(commands, env=env) + if "can\'t use pyrepl" in output: + self.skipTest("pyrepl not available") + self.assertEqual(exit_code, 0) + self.assertIn("True", output) + self.assertNotIn("False", output) + self.assertNotIn("Exception", output) + self.assertNotIn("Traceback", output) + + env["PYTHON_BASIC_REPL"] = "1" + output, exit_code = self.run_repl(commands, env=env) + self.assertEqual(exit_code, 0) + self.assertIn("False", output) + self.assertNotIn("True", output) + self.assertNotIn("Exception", output) + self.assertNotIn("Traceback", output) + def run_repl(self, repl_input: str | list[str], env: dict | None = None) -> tuple[str, int]: master_fd, slave_fd = pty.openpty() process = subprocess.Popen( |