python - 从终端运行命令时收集了 0 个项目
问题描述
我使用下面的代码只是为了检查我的pytest
功能:
class test_001:
def test_addition(self):
assert 1 + 1 == 2
在运行命令时:
pytest -v -s testCases/testme.py
它总是显示Collected 0 items
。
请告诉我我做错了什么。
谢谢并恭祝安康
解决方案
查看pytest 文档上的测试发现,默认是查找名为 test_*.py 或 *_test.py 的文件。如果你有一堂课,那么该堂课应该开始测试。
因此,如果您重命名文件 testCases/test_me.py 并重命名类 IE:
class Test_001:
def test_addition(self):
assert 1+1 == 2
然后pytest会找到它
推荐阅读
- jquery - 如何使用 jquery ajax 将按钮值发布到标签字段
- vb.net - 资产文件 obj\project.assets.json 没有目标“.NETFramework,Version=v4.8/win7-x86” (NETSDK1047)
- python - 使用 on_member_join 时,如何从机器人获取消息以发送到我想要的特定频道?
- c++ - 为什么我不能将带有互斥锁的仿函数传递给线程?
- javascript - 在不知道其结构的情况下在网页中显示 Javascript 对象
- javascript - 在我刷新页面之前,第一个函数无法识别新的 TR
- python - 你能偷偷运行一个python文件吗?
- django - Django Rest Framework - 自定义默认列表视图以显示 ManyToMany 字段的唯一值
- python - 使用正则表达式在两个 json 键之间查找文本
- javascript - 使用javascript动态添加活动到菜单