Created
November 20, 2013 17:53
-
-
Save bbbco/7567794 to your computer and use it in GitHub Desktop.
Robot Framework Python Debugger based on Daniel Cohn's recipe at http://code.activestate.com/recipes/578073-rpdb-robotpythondebugger-a-smarter-way-to-debug-ro/ fixed and updated for Python 2.7 / Robot Framework 2.8.x by Brian Goad. Allows you to jump into the code and debug your custom Python keywords. Wraps pdb because Robot Framework steals th…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pdb | |
import sys | |
IO = lambda s: (s.__stdin__, s.__stdout__) | |
def rpdb(F): | |
""" | |
Robot Framework Python Debugger based on Daniel Cohn's recipe at | |
http://code.activestate.com/recipes/578073-rpdb-robotpythondebugger-a-smarter-way-to-debug-ro/ | |
fixed and updated for Python 2.7 / Robot Framework 2.8.x by Brian Goad. | |
-- | |
usage: | |
@rpdb | |
def keyword_method(self, arg1, arg2, ...): | |
# stuff here ... | |
rpdb.set_trace() # set breakpoint as usual | |
# more code ... | |
""" | |
setattr(rpdb, 'set_trace', pdb.set_trace) | |
builtinIO = IO(sys) | |
def _inner(*args, **kwargs): | |
robotIO = IO(sys) # robot has hijacked stdin/stdout | |
pdb.sys.stdin, pdb.sys.stdout = builtinIO | |
retval = F(*args, **kwargs) | |
sys.__stdin__, sys.__stdout__ = robotIO | |
return retval | |
return _inner | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FWIW, I had to fix the original code by using sys.stdin and sys.stdout ... was clued into this from http://bugs.python.org/issue6333