Skip to content

Commit 119c01d

Browse files
committed
Get rid of spurious output in test_interact.py
1 parent 14805a8 commit 119c01d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/test_pyrepl/test_interact.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ def bar(self):
2727
a
2828
""")
2929
console = InteractiveColoredConsole(namespace, filename="<stdin>")
30+
f = io.StringIO()
3031
with (
3132
patch.object(InteractiveColoredConsole, "showsyntaxerror") as showsyntaxerror,
3233
patch.object(InteractiveColoredConsole, "runsource", wraps=console.runsource) as runsource,
34+
contextlib.redirect_stdout(f),
3335
):
3436
more = console.push(code, filename="<stdin>", _symbol="single") # type: ignore[call-arg]
3537
self.assertFalse(more)
@@ -71,7 +73,9 @@ def test_runsource_compiles_and_runs_code(self):
7173
def test_runsource_returns_false_for_successful_compilation(self):
7274
console = InteractiveColoredConsole()
7375
source = "print('Hello, world!')"
74-
result = console.runsource(source)
76+
f = io.StringIO()
77+
with contextlib.redirect_stdout(f):
78+
result = console.runsource(source)
7579
self.assertFalse(result)
7680

7781
@force_not_colorized

0 commit comments

Comments
 (0)