2024-06-26 15:00:38 发布
网友
我正在使用VS代码+Python测试资源管理器扩展
目前,只有命名约定为test_<somefilename>.py的测试文件被自动发现
test_<somefilename>.py
是否有可以更改的设置,以便它可以检查以不同前缀开头的文件,例如moduletest_<somefilename>.py
moduletest_<somefilename>.py
我真的不想更改这些文件的文件名
谢谢
以下是我的解决方案:
在根目录中创建pytest.ini,测试位于root/tests。在pytest.ini中,添加以下配置:
pytest.ini
root/tests
[pytest] testpaths= tests python_files = moduletest_*.py
在Settings.json中,添加
"python.testing.pytestArgs": [ "-c", "pytest.ini" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true,
然后打开测试资源管理器,moduletest_*.py应该被检测到并显示在那里:
moduletest_*.py
以下是我的解决方案:
在根目录中创建
pytest.ini
,测试位于root/tests
。在pytest.ini
中,添加以下配置:在Settings.json中,添加
然后打开测试资源管理器,
moduletest_*.py
应该被检测到并显示在那里:相关问题 更多 >
编程相关推荐