Skip to content

Commit 3978bdd

Browse files
authored
Merge pull request yidao620c#260 from kerwincsc/patch-8
Update p01_testing_output_sent_to_stdout.rst
2 parents 16d2d7b + 846a70d commit 3978bdd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/c14/p01_testing_output_sent_to_stdout.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
``unittest.mock.patch()`` 函数被用作一个上下文管理器,使用 ``StringIO`` 对象来代替 ``sys.stdout`` .
5858
``fake_out`` 变量是在该进程中被创建的模拟对象。
5959
在with语句中使用它可以执行各种检查。当with语句结束时,``patch`` 会将所有东西恢复到测试开始前的状态。
60-
有一点需要注意的是某些对Python的C扩展可能会忽略掉 ``sys.stdout`` 的配置二直接写入到标准输出中
60+
有一点需要注意的是某些对Python的C扩展可能会忽略掉 ``sys.stdout`` 的配置而直接写入到标准输出中
6161
限于篇幅,本节不会涉及到这方面的讲解,它适用于纯Python代码。
6262
如果你真的需要在C扩展中捕获I/O,你可以先打开一个临时文件,然后将标准输出重定向到该文件中。
6363
更多关于捕获以字符串形式捕获I/O和 ``StringIO`` 对象请参阅5.6小节。

0 commit comments

Comments
 (0)