Debug a test script. `src` is the script, as a string.
(src, pm=False, globs=None)
| 2820 | debug_script(testsrc, pm, globs) |
| 2821 | |
| 2822 | def debug_script(src, pm=False, globs=None): |
| 2823 | "Debug a test script. `src` is the script, as a string." |
| 2824 | import pdb |
| 2825 | |
| 2826 | if globs: |
| 2827 | globs = globs.copy() |
| 2828 | else: |
| 2829 | globs = {} |
| 2830 | |
| 2831 | if pm: |
| 2832 | try: |
| 2833 | exec(src, globs, globs) |
| 2834 | except: |
| 2835 | print(sys.exc_info()[1]) |
| 2836 | p = pdb.Pdb(nosigint=True) |
| 2837 | p.reset() |
| 2838 | p.interaction(None, sys.exc_info()[2]) |
| 2839 | else: |
| 2840 | pdb.Pdb(nosigint=True).run("exec(%r)" % src, globs, globs) |
| 2841 | |
| 2842 | def debug(module, name, pm=False): |
| 2843 | """Debug a single doctest docstring. |