小编Jon*_*n L的帖子

PytestUnknownMarkWarning:未知 pytest.mark.xxx - 这是一个错字吗?

我有一个名为 test.py 的文件,其中包含以下代码:

import pytest

@pytest.mark.webtest
def test_http_request():
    pass

class TestClass:
    def test_method(self):
        pass
Run Code Online (Sandbox Code Playgroud)

pytest -s test.py 通过但给出以下警告:

pytest -s test.py
=============================== test session starts ============================
platform linux -- Python 3.7.3, pytest-5.2.4, py-1.8.0, pluggy-0.13.1
rootdir: /home/user
collected 2 items

test.py ..

=============================== warnings summary ===============================
anaconda3/lib/python3.7/site-packages/_pytest/mark/structures.py:325
  ~/anaconda3/lib/python3.7/site-packages/_pytest/mark/structures.py:325:
    PytestUnknownMarkWarning: Unknown pytest.mark.webtest - is this a typo?  You can register
    custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    PytestUnknownMarkWarning,

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============================== 2 passed, 1 warnings in 0.03s …
Run Code Online (Sandbox Code Playgroud)

pytest python-3.x anaconda3 pytest-markers

21
推荐指数
2
解决办法
1万
查看次数

标签 统计

anaconda3 ×1

pytest ×1

pytest-markers ×1

python-3.x ×1