[英]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.