python - py.test 中如何执行常见的设置和清除工作?

标签 python unit-testing pytest

Python 的 unittest通过将相关函数分组到继承 unittest.TestCase 并提供 setUptearDown 的类中,可以方便地执行常见的设置和清除作业code> 该类的函数。然而,我在py.test中找不到类似的机制。 。我错过了什么?

最佳答案

好的,我已经找到了答案:它被称为“测试 fixture 管理:并在此处讨论:http://agiletesting.blogspot.com/2005/01/python-unit-testing-part-3-pytest-tool.html

关于python - py.test 中如何执行常见的设置和清除工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7252852/

相关文章:

python - 如何检查 Python HTTP 客户端的网络通信?

unit-testing - 功能测试能否替代小型项目中的单元测试

python正则表达式用空格替换所有windows换行符

python - import tensorflow as tf 时导入 Tensorflow 时出错

python - AWS lambda 函数的 mypy 类型 stub

c# - 单元测试适配器在 TeamCity 7.1.5 中抛出没有堆栈跟踪的异常

python - 具有 ModelChoiceField 和模拟数据的 UnitTest ModelForm

python - 如何自定义pytest名称

python - pytest - 将值从一个测试函数传递到测试文件中的另一个

python - 如何避免在 PyTest 中从 session 范围固定装置中改变对象?