pytest.mark ヘルパーを使って、テスト関数にメタデータを簡単に設定できます。組み込みのマーカーを紹介します:
カスタムマーカーを作成する、または全体のテストクラスやモジュールにマーカーを適用するのは簡単です。ドキュメントでもある カスタムマーカーを使う のサンプルを参照してください。
Factory for MarkDecorator objects - exposed as a py.test.mark singleton instance. Example:
import py
@py.test.mark.slowtest
def test_function():
pass
will set a ‘slowtest’ MarkInfo object on the test_function object.
A decorator for test functions and test classes. When applied it will create MarkInfo objects which may be retrieved by hooks as item keywords. MarkDecorator instances are often created like this:
mark1 = py.test.mark.NAME # simple MarkDecorator
mark2 = py.test.mark.NAME(name1=value) # parametrized MarkDecorator
and can then be applied as decorators to test functions:
@mark2
def test_function():
pass