【发布时间】:2021-12-09 06:27:51
【问题描述】:
我的目标是改变在我的 virtualenv 中运行的每个测试,首先是 print("Start test"),一旦测试完成,就变成 print("End of test")。
例如:
def test_numpy_func1():
print("Start test")
method_to_test.run()
print("End test")
我的问题是我需要为 pytest 或 unittest 执行的每个测试执行此任务(手动插入不是一个选项)。
单元测试中是否有任何特定方法可以修改以实现我的目标? 我愿意接受建议。
提前感谢所有帮助者
【问题讨论】:
标签: python unit-testing pytest python-unittest instrumentation