PytestUnknownMarkWarning: Unknown pytest.mark.xxx - is this a typo?
Full error message
I have a file called test.py with the following code:
import pytest
@pytest.mark.webtest
def test_http_request():
pass
class TestClass:
def test_method(self):
pass
pytest -s test.py passed but gave the following warnings:
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 ===================
Environment: Python 3.7.3, pytest 5.2.4, anaconda3
What is the best way to get rid of the warning message?Solutionsource: stackoverflow \u2197
To properly handle this you need to register the custom marker. Create a pytest.ini file and place the following inside of it. [pytest] markers = webtest: mark a test as a webtest. Next time you run the tests, the warning about the unregistered marker will not be there.
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/be65968faf0ceaf7551e083bf275121c03e5656748ea901e51ab7b4389f18291hash \u00b7 be65968faf0ceaf7551e083bf275121c03e5656748ea901e51ab7b4389f18291