Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-133054: Skiptest_pyrepl tests whencannot use pyrepl is reported#133055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sobolevn merged 6 commits intopython:mainfromsobolevn:issue-133054
Apr 28, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletionsLib/test/test_pyrepl/test_pyrepl.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,14 +44,15 @@ def run_repl(
*,
cmdline_args: list[str] | None = None,
cwd: str | None = None,
skip: bool = False,
) -> tuple[str, int]:
temp_dir = None
if cwd is None:
temp_dir = tempfile.TemporaryDirectory(ignore_cleanup_errors=True)
cwd = temp_dir.name
try:
return self._run_repl(
repl_input, env=env, cmdline_args=cmdline_args, cwd=cwd
repl_input, env=env, cmdline_args=cmdline_args, cwd=cwd, skip=skip,
)
finally:
if temp_dir is not None:
Expand All@@ -64,6 +65,7 @@ def _run_repl(
env: dict | None,
cmdline_args: list[str] | None,
cwd: str,
skip: bool,
) -> tuple[str, int]:
assert pty
master_fd, slave_fd = pty.openpty()
Expand DownExpand Up@@ -121,7 +123,10 @@ def _run_repl(
except subprocess.TimeoutExpired:
process.kill()
exit_code = process.wait()
return "".join(output), exit_code
output = "".join(output)
if skip and "can't use pyrepl" in output:
self.skipTest("pyrepl not available")
return output, exit_code


class TestCursorPosition(TestCase):
Expand DownExpand Up@@ -1282,9 +1287,7 @@ def setUp(self):
def test_exposed_globals_in_repl(self):
pre = "['__builtins__'"
post = "'__loader__', '__name__', '__package__', '__spec__']"
output, exit_code = self.run_repl(["sorted(dir())", "exit()"])
if "can't use pyrepl" in output:
self.skipTest("pyrepl not available")
output, exit_code = self.run_repl(["sorted(dir())", "exit()"], skip=True)
self.assertEqual(exit_code, 0)

# if `__main__` is not a file (impossible with pyrepl)
Expand DownExpand Up@@ -1336,20 +1339,19 @@ def _run_repl_globals_test(self, expectations, *, as_file=False, as_module=False
commands,
cmdline_args=[str(mod)],
env=clean_env,
skip=True,
)
elif as_module:
output, exit_code = self.run_repl(
commands,
cmdline_args=["-m", "blue.calx"],
env=clean_env,
cwd=td,
skip=True,
)
else:
self.fail("Choose one of as_file or as_module")

if "can't use pyrepl" in output:
self.skipTest("pyrepl not available")

self.assertEqual(exit_code, 0)
for var, expected in expectations.items():
with self.subTest(var=var, expected=expected):
Expand DownExpand Up@@ -1387,9 +1389,7 @@ def test_python_basic_repl(self):
"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")
output, exit_code = self.run_repl(commands, env=env, skip=True)
self.assertEqual(exit_code, 0)
self.assertIn("True", output)
self.assertNotIn("False", output)
Expand DownExpand Up@@ -1456,9 +1456,7 @@ def check(output, exitcode):
self.assertIn("division by zero", output)
self.assertEqual(exitcode, 0)
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")
output, exit_code = self.run_repl(commands, env=env, skip=True)
check(output, exit_code)

env["PYTHON_BASIC_REPL"] = "1"
Expand DownExpand Up@@ -1496,9 +1494,7 @@ def test_not_wiping_history_file(self):
def test_correct_filename_in_syntaxerrors(self):
env = os.environ.copy()
commands = "a b c\nexit()\n"
output, exit_code = self.run_repl(commands, env=env)
if "can't use pyrepl" in output:
self.skipTest("pyrepl not available")
output, exit_code = self.run_repl(commands, env=env, skip=True)
self.assertIn("SyntaxError: invalid syntax", output)
self.assertIn("<python-input-0>", output)
commands = " b\nexit()\n"
Expand All@@ -1525,9 +1521,7 @@ def test_proper_tracebacklimit(self):
env.pop("PYTHON_BASIC_REPL", None)
with self.subTest(set_tracebacklimit=set_tracebacklimit,
basic_repl=basic_repl):
output, exit_code = self.run_repl(commands, env=env)
if "can't use pyrepl" in output:
self.skipTest("pyrepl not available")
output, exit_code = self.run_repl(commands, env=env, skip=True)
self.assertIn("in x1", output)
if set_tracebacklimit:
self.assertNotIn("in x2", output)
Expand DownExpand Up@@ -1568,9 +1562,7 @@ def test_readline_history_file(self):
def test_history_survive_crash(self):
env = os.environ.copy()
commands = "1\nexit()\n"
output, exit_code = self.run_repl(commands, env=env)
if "can't use pyrepl" in output:
self.skipTest("pyrepl not available")
output, exit_code = self.run_repl(commands, env=env, skip=True)

with tempfile.NamedTemporaryFile() as hfile:
env["PYTHON_HISTORY"] = hfile.name
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp