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)
| 88 | return u'' |
| 89 | |
| 90 | def 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 |
nothing calls this directly
no outgoing calls
no test coverage detected