mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
gh-128770: fix ResourceWarning in test_pyrepl (#128906)
This commit is contained in:
parent
a16ded10ad
commit
24c84d816f
1 changed files with 13 additions and 14 deletions
|
@ -1324,22 +1324,21 @@ class TestMain(ReplTestCase):
|
||||||
if readline.backend != "editline":
|
if readline.backend != "editline":
|
||||||
self.skipTest("GNU readline is not affected by this issue")
|
self.skipTest("GNU readline is not affected by this issue")
|
||||||
|
|
||||||
hfile = tempfile.NamedTemporaryFile()
|
with tempfile.NamedTemporaryFile() as hfile:
|
||||||
self.addCleanup(unlink, hfile.name)
|
env = os.environ.copy()
|
||||||
env = os.environ.copy()
|
env["PYTHON_HISTORY"] = hfile.name
|
||||||
env["PYTHON_HISTORY"] = hfile.name
|
|
||||||
|
|
||||||
env["PYTHON_BASIC_REPL"] = "1"
|
env["PYTHON_BASIC_REPL"] = "1"
|
||||||
output, exit_code = self.run_repl("spam \nexit()\n", env=env)
|
output, exit_code = self.run_repl("spam \nexit()\n", env=env)
|
||||||
self.assertEqual(exit_code, 0)
|
self.assertEqual(exit_code, 0)
|
||||||
self.assertIn("spam ", output)
|
self.assertIn("spam ", output)
|
||||||
self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
|
self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
|
||||||
self.assertIn("spam\\040", pathlib.Path(hfile.name).read_text())
|
self.assertIn("spam\\040", pathlib.Path(hfile.name).read_text())
|
||||||
|
|
||||||
env.pop("PYTHON_BASIC_REPL", None)
|
env.pop("PYTHON_BASIC_REPL", None)
|
||||||
output, exit_code = self.run_repl("exit\n", env=env)
|
output, exit_code = self.run_repl("exit\n", env=env)
|
||||||
self.assertEqual(exit_code, 0)
|
self.assertEqual(exit_code, 0)
|
||||||
self.assertNotIn("\\040", pathlib.Path(hfile.name).read_text())
|
self.assertNotIn("\\040", pathlib.Path(hfile.name).read_text())
|
||||||
|
|
||||||
def test_keyboard_interrupt_after_isearch(self):
|
def test_keyboard_interrupt_after_isearch(self):
|
||||||
output, exit_code = self.run_repl(["\x12", "\x03", "exit"])
|
output, exit_code = self.run_repl(["\x12", "\x03", "exit"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue