Warnings in Python Testing With Pytest Chapter 2

Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks”

While running the smoke tests in Chapter 2, I get these warnings:

tests/func/test_add.py:18
  /Users/telemachus/Downloads/pytest-code/ch2/tasks_proj/tests/func/test_add.py:18: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    @pytest.mark.smoke

tests/func/test_api_exceptions.py:13
  /Users/telemachus/Downloads/pytest-code/ch2/tasks_proj/tests/func/test_api_exceptions.py:13: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    @pytest.mark.smoke

tests/func/test_api_exceptions.py:20
  /Users/telemachus/Downloads/pytest-code/ch2/tasks_proj/tests/func/test_api_exceptions.py:20: PytestUnknownMarkWarning: Unknown pytest.mark.get - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    @pytest.mark.get

tests/func/test_api_exceptions.py:21
  /Users/telemachus/Downloads/pytest-code/ch2/tasks_proj/tests/func/test_api_exceptions.py:21: PytestUnknownMarkWarning: Unknown pytest.mark.smoke - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
    @pytest.mark.smoke

-- Docs: https://docs.pytest.org/en/latest/warnings.html

Happily, pytest has great error messages, and this was pretty easy to fix. I just added information to pytest.ini. But if the book gets an update, you should probably update the code for the latest pytest API. (I’m guessing that you didn’t use to have to register custom marks this way?)

2 Likes

Great of you to point this out.
Yes, I recommend adding the following to pytest.ini:

[pytest]
markers =
    smoke
    get
3 Likes