Skip to content

Commit 2d86e42

Browse files
committed
ci-test
1 parent a29eefb commit 2d86e42

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

IPython/core/interactiveshell.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,12 @@ def input_transformers_cleanup(self):
543543
help="Warn if running in a virtual environment with no IPython installed (so IPython from the global environment is used).",
544544
).tag(config=True)
545545

546+
# Flag to disable the custom CapturingTee mechanism.
547+
# Useful in test environments to use the standard capturing of stdout/stderr.
548+
disable_capturing_tee = Bool(
549+
False, help="Disable the custom CapturingTee output capturing"
550+
).tag(config=True)
551+
546552
# TODO: this part of prompt management should be moved to the frontends.
547553
# Use custom TraitTypes that convert '0'->'' and '\\n'->'\n'
548554
separate_in = SeparateUnicode('\n').tag(config=True)
@@ -3040,15 +3046,20 @@ def run_cell(
30403046
result : :class:`ExecutionResult`
30413047
"""
30423048
result = None
3043-
tee_out = CapturingTee(self, channel="stdout")
3044-
tee_err = CapturingTee(self, channel="stderr")
3049+
tee_out = None
3050+
tee_err = None
3051+
if not self.disable_capturing_tee:
3052+
tee_out = CapturingTee(self, channel="stdout")
3053+
tee_err = CapturingTee(self, channel="stderr")
30453054
try:
30463055
result = self._run_cell(
30473056
raw_cell, store_history, silent, shell_futures, cell_id
30483057
)
30493058
finally:
3050-
tee_out.close()
3051-
tee_err.close()
3059+
if tee_out is not None:
3060+
tee_out.close()
3061+
if tee_err is not None:
3062+
tee_err.close()
30523063
self.events.trigger('post_execute')
30533064
if not silent:
30543065
self.events.trigger('post_run_cell', result)

tests/test_magic_terminal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_paste_py_multi(self):
132132
>>> y = []
133133
>>> for i in x:
134134
... y.append(i**2)
135-
...
135+
...
136136
"""
137137
)
138138
self.assertEqual(ip.user_ns["x"], [1, 2, 3])
@@ -174,7 +174,7 @@ def test_paste_email_py(self):
174174
"""\
175175
>> >>> def f(x):
176176
>> ... return x+1
177-
>> ...
177+
>> ...
178178
>> >>> zz = f(2.5) """
179179
)
180180
self.assertEqual(ip.user_ns["zz"], 3.5)
@@ -188,10 +188,12 @@ def test_paste_echo(self):
188188
a = 100
189189
b = 200"""
190190
try:
191+
ip.disable_capturing_tee = True
191192
self.paste(code, "")
192193
out = w.getvalue()
193194
finally:
194195
sys.stdout.write = old_write
196+
ip.disable_capturing_tee = False
195197
self.assertEqual(ip.user_ns["a"], 100)
196198
self.assertEqual(ip.user_ns["b"], 200)
197199
assert out == code + "\n## -- End pasted text --\n"

tests/test_oinspect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,12 @@ def prop(self):
517517
Docstring for prop
518518
'''
519519
return self._prop
520-
520+
521521
@prop.setter
522522
def prop(self, v):
523523
self._prop = v
524524
"""
525+
ip.disable_capturing_tee = True
525526
ip.run_cell(obj_def)
526527

527528
ip.run_cell("b = Bar()")
@@ -545,6 +546,7 @@ def prop(self, v):
545546
ip.run_cell("b.undefined?")
546547
captured = capsys.readouterr()
547548
assert re.search(r"Type:\s+NoneType", captured.out)
549+
ip.disable_capturing_tee = False
548550

549551

550552
def test_pinfo_magic():

0 commit comments

Comments
 (0)