mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
[3.13] gh-121016: Add test for PYTHON_BASIC_REPL envioronment variable (GH-121017) (#121064)
* gh-121016: Add test for `PYTHON_BASIC_REPL` envioronment variable (#121017) (cherry picked from commit9e45fd9858
) * [3.13] gh-121016: Add test for `PYTHON_BASIC_REPL` envioronment variable (GH-121017) (cherry picked from commit9e45fd9858
) Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
This commit is contained in:
parent
d7cd71c72a
commit
bc515b332b
2 changed files with 31 additions and 0 deletions
|
@ -873,6 +873,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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue