summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pyrepl/test_interact.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-23 17:58:59 (GMT)
committerGitHub <noreply@github.com>2024-05-23 17:58:59 (GMT)
commit8fd8cc564bea243e30cc8881a9981ab85e09fe81 (patch)
tree198e9c79100b8147be5e12d28fea78145eeab69b /Lib/test/test_pyrepl/test_interact.py
parent251ef2e36f61a1c4b7c628ba9dc38a10a355a058 (diff)
downloadcpython-8fd8cc564bea243e30cc8881a9981ab85e09fe81.zip
cpython-8fd8cc564bea243e30cc8881a9981ab85e09fe81.tar.gz
cpython-8fd8cc564bea243e30cc8881a9981ab85e09fe81.tar.bz2
[3.13] gh-119469: Fix _pyrepl reference leaks (GH-119470) (#119471)
(cherry picked from commit 6e012ced6cc07a7502278e1849c5618d1ab54a08) Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/test/test_pyrepl/test_interact.py')
-rw-r--r--Lib/test/test_pyrepl/test_interact.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_pyrepl/test_interact.py b/Lib/test/test_pyrepl/test_interact.py
index b3dc07c..10e3404 100644
--- a/Lib/test/test_pyrepl/test_interact.py
+++ b/Lib/test/test_pyrepl/test_interact.py
@@ -27,9 +27,11 @@ class TestSimpleInteract(unittest.TestCase):
a
""")
console = InteractiveColoredConsole(namespace, filename="<stdin>")
+ f = io.StringIO()
with (
patch.object(InteractiveColoredConsole, "showsyntaxerror") as showsyntaxerror,
patch.object(InteractiveColoredConsole, "runsource", wraps=console.runsource) as runsource,
+ contextlib.redirect_stdout(f),
):
more = console.push(code, filename="<stdin>", _symbol="single") # type: ignore[call-arg]
self.assertFalse(more)
@@ -71,7 +73,9 @@ class TestSimpleInteract(unittest.TestCase):
def test_runsource_returns_false_for_successful_compilation(self):
console = InteractiveColoredConsole()
source = "print('Hello, world!')"
- result = console.runsource(source)
+ f = io.StringIO()
+ with contextlib.redirect_stdout(f):
+ result = console.runsource(source)
self.assertFalse(result)
@force_not_colorized