擅长:python、mysql、java
<p>您可以有一个变量来跟踪正确执行的函数或以异常结束的函数。</p>
<pre><code>def func_A():
function_state = True
try:
# do some stuff
except Exception as e:
log.error("there was an exception %s", str(e))
function_state = False
return function_state
</code></pre>
<p>使用<code>assertTrue</code>验证<code>function_state</code>。</p>