A fake input stream for pdb's interactive debugger. Whenever a line is read, print it (to simulate the user typing it), and then return it. The set of lines to return is specified in the constructor; they should not have trailing newlines.
| 28 | #----------------------------------------------------------------------------- |
| 29 | |
| 30 | class _FakeInput(object): |
| 31 | """ |
| 32 | A fake input stream for pdb's interactive debugger. Whenever a |
| 33 | line is read, print it (to simulate the user typing it), and then |
| 34 | return it. The set of lines to return is specified in the |
| 35 | constructor; they should not have trailing newlines. |
| 36 | """ |
| 37 | def __init__(self, lines): |
| 38 | self.lines = iter(lines) |
| 39 | |
| 40 | def readline(self): |
| 41 | line = next(self.lines) |
| 42 | print(line) |
| 43 | return line+'\n' |
| 44 | |
| 45 | class PdbTestInput(object): |
| 46 | """Context manager that makes testing Pdb in doctests easier.""" |