Skip to content

Add methods for redirecting output back to stdout for debugging purposes #147

@emanlove

Description

@emanlove

In the To-Be-Completed section "Debugging Selenium2Library" under BUILD.rst add the various methods for redirecting output

Chris Prinos [1]

import pdb; pdb.Pdb(stdout=sys.__stdout__).set_trace()

Asko Soukka

need to re-find Asko's solution

Daniel Cohn [3]

import pdb

IO = lambda s: (s.stdin, s.stdout)

def rpdb(F):
    """
    robot python debugger -- 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions