Debug a test script. `src` is the script, as a string.
(src, pm=False, globs=None)
| 2744 | debug_script(testsrc, pm, globs) |
| 2745 | |
| 2746 | def debug_script(src, pm=False, globs=None): |
| 2747 | "Debug a test script. `src` is the script, as a string." |
| 2748 | import pdb |
| 2749 | |
| 2750 | if globs: |
| 2751 | globs = globs.copy() |
| 2752 | else: |
| 2753 | globs = {} |
| 2754 | |
| 2755 | if pm: |
| 2756 | try: |
| 2757 | exec(src, globs, globs) |
| 2758 | except: |
| 2759 | print(sys.exc_info()[1]) |
| 2760 | p = pdb.Pdb(nosigint=True) |
| 2761 | p.reset() |
| 2762 | p.interaction(None, sys.exc_info()[2]) |
| 2763 | else: |
| 2764 | pdb.Pdb(nosigint=True).run("exec(%r)" % src, globs, globs) |
| 2765 | |
| 2766 | def debug(module, name, pm=False): |
| 2767 | """Debug a single doctest docstring. |