MCPcopy Create free account
hub / github.com/ipython/ipython / mock_input

Function mock_input

IPython/terminal/tests/test_interactivshell.py:90–109  ·  view source on GitHub ↗

Decorator for tests of the main interact loop. Write the test as a generator, yield-ing the input strings, which IPython will see as if they were typed in at the prompt.

(testfunc)

Source from the content-addressed store, hash-verified

88 return u''
89
90def mock_input(testfunc):
91 """Decorator for tests of the main interact loop.
92
93 Write the test as a generator, yield-ing the input strings, which IPython
94 will see as if they were typed in at the prompt.
95 """
96 def test_method(self):
97 testgen = testfunc(self)
98 with mock_input_helper(testgen) as mih:
99 mih.ip.interact()
100
101 if mih.exception is not None:
102 # Re-raise captured exception
103 etype, value, tb = mih.exception
104 import traceback
105 traceback.print_tb(tb, file=sys.stdout)
106 del tb # Avoid reference loop
107 raise value
108
109 return test_method
110
111# Test classes -----------------------------------------------------------------
112

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected