擅长:python、mysql、java
<p>关键是<a href="http://docs.python.org/2/library/unittest.html#cmdoption-unittest-b" rel="nofollow"><em>buffer</em> option</a>会影响在测试中编写stdout,而忽略unittest2行为的影响。也就是说,如果您添加字符串</p>
<pre><code>print "Suppress me!"
</code></pre>
<p>对于任何测试方法,如果选择<code>buffer=False</code>,则此表达式将出现在stdout上,而如果将其设置为True,则它将被抑制。</p>