Skip to content

Commit 2e21fb5

Browse files
committed
Adapt pyrepl discovery to the new transparent reality
1 parent 3d76ed8 commit 2e21fb5

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

Lib/test/support/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,12 +2929,6 @@ def make_clean_env() -> dict[str, str]:
29292929
return clean_env
29302930

29312931

2932-
def initialized_with_pyrepl():
2933-
"""Detect whether PyREPL was used during Python initialization."""
2934-
# If the main module has a __file__ attribute it's a Python module, which means PyREPL.
2935-
return hasattr(sys.modules["__main__"], "__file__")
2936-
2937-
29382932
WINDOWS_STATUS = {
29392933
0xC0000005: "STATUS_ACCESS_VIOLATION",
29402934
0xC00000FD: "STATUS_STACK_OVERFLOW",

Lib/test/test_pyrepl/test_pyrepl.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,23 +1400,19 @@ def test_inspect_keeps_globals_from_inspected_module(self):
14001400
@force_not_colorized
14011401
def test_python_basic_repl(self):
14021402
env = os.environ.copy()
1403-
commands = ("from test.support import initialized_with_pyrepl\n"
1404-
"initialized_with_pyrepl()\n"
1405-
"exit()\n")
1406-
1403+
pyrepl_commands = "clear\nexit()\n"
14071404
env.pop("PYTHON_BASIC_REPL", None)
1408-
output, exit_code = self.run_repl(commands, env=env, skip=True)
1405+
output, exit_code = self.run_repl(pyrepl_commands, env=env, skip=True)
14091406
self.assertEqual(exit_code, 0)
1410-
self.assertIn("True", output)
1411-
self.assertNotIn("False", output)
14121407
self.assertNotIn("Exception", output)
1408+
self.assertNotIn("NameError", output)
14131409
self.assertNotIn("Traceback", output)
14141410

1411+
basic_commands = "help\nexit()\n"
14151412
env["PYTHON_BASIC_REPL"] = "1"
1416-
output, exit_code = self.run_repl(commands, env=env)
1413+
output, exit_code = self.run_repl(basic_commands, env=env)
14171414
self.assertEqual(exit_code, 0)
1418-
self.assertIn("False", output)
1419-
self.assertNotIn("True", output)
1415+
self.assertIn("Type help() for interactive help", output)
14201416
self.assertNotIn("Exception", output)
14211417
self.assertNotIn("Traceback", output)
14221418

0 commit comments

Comments
 (0)