rdkit.TestRunner module

class rdkit.TestRunner.OutputRedirectC(stdout='/dev/null', stderr='/dev/null', mode='wb')

Bases: object

Context manager which uses low-level file descriptors to suppress output to stdout/stderr, optionally redirecting to the named file(s).

Suppress all output with Silence():

<code>

Redirect stdout to file with OutputRedirectC(stdout=’output.txt’, mode=’w’):

<code>

Redirect stderr to file with OutputRedirectC(stderr=’output.txt’, mode=’a’):

<code>

http://code.activestate.com/recipes/577564-context-manager-for-low-level-redirection-of-stdou/ >>>

rdkit.TestRunner.isDebugBuild()
class rdkit.TestRunner.redirect_stderr(new_target)

Bases: _RedirectStream

Context manager for temporarily redirecting stderr to another file.

class rdkit.TestRunner.redirect_stdout(new_target)

Bases: _RedirectStream

Context manager for temporarily redirecting stdout to another file.

# How to send help() to stderr with redirect_stdout(sys.stderr):

help(dir)

# How to write help() to a file with open(‘help.txt’, ‘w’) as f:

with redirect_stdout(f):

help(pow)