[英]pytest doesn't run any test
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 ==============================================
要确定测试未运行的原因,以下步骤很有用:
pytest.ini
文件。__init__.py
文件。您需要所有测试都以test_
开头,但您还需要告诉 Pytest 确切要查找的文件:
# pytest.ini
[pytest]
DJANGO_SETTIONS_MODULE = myproject.settings
python_files = tests.py test_*.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.