[サンプルテストスクリプト] my_test.py
import pytest @pytest.mark.run def test_hello(): assert True
[実行結果]
$ pytest my_test.py -m run === test session starts === 〜省略〜 collected 1 item my_test.py . [100%] 〜省略〜 You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html PytestUnknownMarkWarning
一応、テストは行えているがワーニングが出るのが気持ち悪い。
ワーニングメッセージにしたがって、https://docs.pytest.org/en/latest/mark.htmlを読んでみたところ、pytest.iniに使用するマーカーを登録すればいいらしい。
テストのルートディレクトリにpytest.iniを作成し、以下のコードを書く。
[pytest] markers = run
もう一度、pytestを実行すると今度はワーニングが表示されない。