我有一个应用程序,我的单元测试是这样组织的:
server/
tests/
conftest.py
test_server.py
client/
tests/
conftest.py
test_client.py在这个设置中,没有重复的夹具配置,因为conftest.py文件只为它们的相关测试安装了补丁。
现在,我正在添加集成测试,组织方式如下:
tests/
conftest.py
test_integration.py
server/
tests/
conftest.py
test_server.py
client/
tests/
conftest.py
test_client.py这个新的conftest.py需要所有的,这是我在其他地方定义的夹具。如何设置py.test以避免复制来自client/tests/conftest.py和server/tests/conftest.py的所有夹具
最相似的问题是:How to organize fixtures when using pytest
谢谢!
发布于 2014-06-09 12:49:27
我处理这种情况的方法是将共享的所有设备移动到如下所示的toplevel甜点文件中:
conftest.py
tests/
[conftest.py]
test_integration.py
server/
tests/
[conftest.py]
test_server.py
client/
tests/
[conftest.py]
test_client.py这确实使它有时变得不太好,因为您最终在toplevel conftest.py中得到了一堆不太相关的固定装置,但是它很简单,而且很明显。
https://stackoverflow.com/questions/24111840
复制相似问题