pytest doesn#39;t run any test(pytest不会运行任何测试)
本文介绍了pytest不会运行任何测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
pytest不运行任何测试,原因尚不清楚。我试图使用--debug,但没有获得任何有价值的信息。完全不清楚如何用pytest调试这类问题。(看起来可能是pytest配置/环境变量/测试名称模式有问题?)
测试文件示例:
import pytest
@pytest.mark.sanity
def test_me():
"""I'm a test."""
assert True
但是pytest不运行任何测试,为什么?
$ pytest
================================================== test session starts ===================================================
platform linux2 -- Python 2.7.12, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /home/qawizard/pytest-hell, inifile:
plugins: xdist-1.15.0, timeout-1.2.0
collected 1 item s
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Exit: Done! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================== no tests ran in 0.13 seconds ==============================================
推荐答案
要确定测试未运行的原因,以下步骤很有用:
- 验证具有测试用例的所有文件是否都以"test_"Word开头。
- 验证所有测试用例名称是否也以"test_"单词开头。
- 请确认您已在根目录中创建了
pytest.ini
文件。 - 请确认您在项目的所有目录/子目录中都有
__init__.py
文件。
这篇关于pytest不会运行任何测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:pytest不会运行任何测试


基础教程推荐
猜你喜欢
- 使 Python 脚本在 Windows 上运行而不指定“.py";延期 2022-01-01
- 哪些 Python 包提供独立的事件系统? 2022-01-01
- 症状类型错误:无法确定关系的真值 2022-01-01
- 使用Python匹配Stata加权xtil命令的确定方法? 2022-01-01
- 使用 Google App Engine (Python) 将文件上传到 Google Cloud Storage 2022-01-01
- 如何在 Python 中检测文件是否为二进制(非文本)文 2022-01-01
- 合并具有多索引的两个数据帧 2022-01-01
- 如何在Python中绘制多元函数? 2022-01-01
- Python 的 List 是如何实现的? 2022-01-01
- 将 YAML 文件转换为 python dict 2022-01-01