轻松捕获stdout和stderr。
项目描述
.. -*- restructuredtext -*-
.. highlight:: python
.. image:: https://secure.travis-ci.org/oinume/iocapture.png?branch=master
使用iocapture轻松捕获stdout和stderr。
如何使用
==========
Python >= 2.5:
import iocapture
with iocapture.capture() as captured
print("hello stdout")
print(captured.stdout)
# >>> hello stdout
Python < 2.5:
import iocapture
captured = iocapture.capture()
captured.start()
print("hello stdout")
captured.close()
print(captured.stdout)
# >>> hello stdout
变更日志
=========
https://github.com/oinume/blob/master/changes.rst
对于开发者
==============
以开发模式安装iocapture:
$ python setup.py develop
安装以下模块进行测试:
$ pip install -r requirements-dev.txt
运行测试:
$ py.test tests
.. highlight:: python
.. image:: https://secure.travis-ci.org/oinume/iocapture.png?branch=master
使用iocapture轻松捕获stdout和stderr。
如何使用
==========
Python >= 2.5:
import iocapture
with iocapture.capture() as captured
print("hello stdout")
print(captured.stdout)
# >>> hello stdout
Python < 2.5:
import iocapture
captured = iocapture.capture()
captured.start()
print("hello stdout")
captured.close()
print(captured.stdout)
# >>> hello stdout
变更日志
=========
https://github.com/oinume/blob/master/changes.rst
对于开发者
==============
以开发模式安装iocapture:
$ python setup.py develop
安装以下模块进行测试:
$ pip install -r requirements-dev.txt
运行测试:
$ py.test tests