Test calling some IPython magics from ipdb. First, set up some test functions and classes which we can inspect. >>> class ExampleClass(object): ... """Docstring for ExampleClass.""" ... def __init__(self): ... """Docstring for ExampleClass.__init__""" ...
()
| 77 | nt.assert_equal(trepr(a), ar) |
| 78 | |
| 79 | def test_ipdb_magics(): |
| 80 | '''Test calling some IPython magics from ipdb. |
| 81 | |
| 82 | First, set up some test functions and classes which we can inspect. |
| 83 | |
| 84 | >>> class ExampleClass(object): |
| 85 | ... """Docstring for ExampleClass.""" |
| 86 | ... def __init__(self): |
| 87 | ... """Docstring for ExampleClass.__init__""" |
| 88 | ... pass |
| 89 | ... def __str__(self): |
| 90 | ... return "ExampleClass()" |
| 91 | |
| 92 | >>> def example_function(x, y, z="hello"): |
| 93 | ... """Docstring for example_function.""" |
| 94 | ... pass |
| 95 | |
| 96 | >>> old_trace = sys.gettrace() |
| 97 | |
| 98 | Create a function which triggers ipdb. |
| 99 | |
| 100 | >>> def trigger_ipdb(): |
| 101 | ... a = ExampleClass() |
| 102 | ... debugger.Pdb().set_trace() |
| 103 | |
| 104 | >>> with PdbTestInput([ |
| 105 | ... 'pdef example_function', |
| 106 | ... 'pdoc ExampleClass', |
| 107 | ... 'up', |
| 108 | ... 'down', |
| 109 | ... 'list', |
| 110 | ... 'pinfo a', |
| 111 | ... 'll', |
| 112 | ... 'continue', |
| 113 | ... ]): |
| 114 | ... trigger_ipdb() |
| 115 | --Return-- |
| 116 | None |
| 117 | > <doctest ...>(3)trigger_ipdb() |
| 118 | 1 def trigger_ipdb(): |
| 119 | 2 a = ExampleClass() |
| 120 | ----> 3 debugger.Pdb().set_trace() |
| 121 | <BLANKLINE> |
| 122 | ipdb> pdef example_function |
| 123 | example_function(x, y, z='hello') |
| 124 | ipdb> pdoc ExampleClass |
| 125 | Class docstring: |
| 126 | Docstring for ExampleClass. |
| 127 | Init docstring: |
| 128 | Docstring for ExampleClass.__init__ |
| 129 | ipdb> up |
| 130 | > <doctest ...>(11)<module>() |
| 131 | 7 'pinfo a', |
| 132 | 8 'll', |
| 133 | 9 'continue', |
| 134 | 10 ]): |
| 135 | ---> 11 trigger_ipdb() |
| 136 | <BLANKLINE> |
nothing calls this directly
no outgoing calls
no test coverage detected