python - 在扭曲试验中超时后没有调用 tearDown?

标签 python testing twisted trial

我在试用版测试套件中发现了一个问题,在出现超时之前一切正常。如果测试由于超时而失败,则永远不会调用 tearDown 函数,从而使 react 堆不干净,进而导致其余测试失败。我认为 tearDown 应该在超时后调用,有人知道为什么会发生这种情况吗?

最佳答案

无论测试中发生什么,都应该调用 tearDown() 是正确的。来自 the documentation对于 tearDown():

This is called even if the test method raised an exception

但是,有一个问题。来自同一文档:

This method will only be called if the setUp() succeeds, regardless of the outcome of the test method.

所以听起来你可能在 setUp() 中启动 react 堆,当它超时时,这会阻止你的 tearDown() 运行 - 这个想法是无论您在 setUp() 中尝试“设置”什么,都成功设置,因此您不想尝试将其拆除。但是,除非您提供 setUptearDown 方法的代码,以及任何相关测试的代码,否则很难做出准确的诊断。

关于python - 在扭曲试验中超时后没有调用 tearDown?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39883058/

相关文章:

https - 在 https 上扭曲

php - docker compose - 将 python 添加到 LAMP

python:如何直接在另一个包中调用一个包中的模块中的构造函数

Python Eric IDE : Execute selection in console

testing - Tomcat测试和生产环境

java - 我如何测试这个 rxJava 代码?

Python:如何以编程方式更新属性?

android - 如何用JUNIT测试ui应用程序android并截图

Python Twisted - 如何为 twisted.logger 设置日志级别

linux - Fedora 或 CentOS 中的 Twisted 设置