diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/tools/py/doc/io.txt | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/tools/py/doc/io.txt')
-rw-r--r-- | testing/web-platform/tests/tools/py/doc/io.txt | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/py/doc/io.txt b/testing/web-platform/tests/tools/py/doc/io.txt new file mode 100644 index 000000000..c11308a6d --- /dev/null +++ b/testing/web-platform/tests/tools/py/doc/io.txt @@ -0,0 +1,59 @@ +======= +py.io +======= + + +The 'py' lib provides helper classes for capturing IO during +execution of a program. + +IO Capturing examples +=============================================== + +``py.io.StdCapture`` +--------------------------- + +Basic Example:: + + >>> import py + >>> capture = py.io.StdCapture() + >>> print "hello" + >>> out,err = capture.reset() + >>> out.strip() == "hello" + True + +For calling functions you may use a shortcut:: + + >>> import py + >>> def f(): print "hello" + >>> res, out, err = py.io.StdCapture.call(f) + >>> out.strip() == "hello" + True + +``py.io.StdCaptureFD`` +--------------------------- + +If you also want to capture writes to the stdout/stderr +filedescriptors you may invoke:: + + >>> import py, sys + >>> capture = py.io.StdCaptureFD(out=False, in_=False) + >>> sys.stderr.write("world") + >>> out,err = capture.reset() + >>> err + 'world' + +py.io object reference +============================ + +.. autoclass:: py.io.StdCaptureFD + :members: + :inherited-members: + +.. autoclass:: py.io.StdCapture + :members: + :inherited-members: + +.. autoclass:: py.io.TerminalWriter + :members: + :inherited-members: + |