2009-10-23 02:57:21 +08:00
|
|
|
|
2010-10-11 05:45:45 +08:00
|
|
|
.. _mark:
|
|
|
|
|
2011-09-06 17:43:42 +08:00
|
|
|
Marking test functions with attributes
|
2010-10-13 18:26:14 +08:00
|
|
|
=================================================================
|
2010-01-13 23:00:33 +08:00
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
|
2011-11-12 06:56:06 +08:00
|
|
|
By using the ``pytest.mark`` helper you can easily set
|
2011-11-19 02:32:11 +08:00
|
|
|
metadata on your test functions. There are
|
2011-11-12 06:56:06 +08:00
|
|
|
some builtin markers, for example:
|
2009-10-23 02:57:21 +08:00
|
|
|
|
2017-08-04 09:00:11 +08:00
|
|
|
* :ref:`skip <skip>` - always skip a test function
|
2011-11-17 19:09:21 +08:00
|
|
|
* :ref:`skipif <skipif>` - skip a test function if a certain condition is met
|
|
|
|
* :ref:`xfail <xfail>` - produce an "expected failure" outcome if a certain
|
2011-11-12 06:56:06 +08:00
|
|
|
condition is met
|
2011-11-17 19:09:21 +08:00
|
|
|
* :ref:`parametrize <parametrizemark>` to perform multiple calls
|
|
|
|
to the same test function.
|
2011-11-12 06:56:06 +08:00
|
|
|
|
2011-11-19 02:32:11 +08:00
|
|
|
It's easy to create custom markers or to apply markers
|
|
|
|
to whole test classes or modules. See :ref:`mark examples` for examples
|
|
|
|
which also serve as documentation.
|
2011-11-12 06:56:06 +08:00
|
|
|
|
2015-08-28 07:11:07 +08:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
Marks can only be applied to tests, having no effect on
|
|
|
|
:ref:`fixtures <fixtures>`.
|
|
|
|
|
2010-10-14 01:30:00 +08:00
|
|
|
|