Updating markers example to newest pytest version

This commit is contained in:
Kanguros 2018-12-16 21:13:14 +01:00
parent b76104e722
commit 60773e0a97
1 changed files with 1 additions and 10 deletions

View File

@ -308,7 +308,7 @@ apply a marker to an individual test instance::
@pytest.mark.foo @pytest.mark.foo
@pytest.mark.parametrize(("n", "expected"), [ @pytest.mark.parametrize(("n", "expected"), [
(1, 2), (1, 2),
pytest.mark.bar((1, 3)), pytest.param((1, 3), marks=pytest.mark.bar),
(2, 3), (2, 3),
]) ])
def test_increment(n, expected): def test_increment(n, expected):
@ -318,15 +318,6 @@ In this example the mark "foo" will apply to each of the three
tests, whereas the "bar" mark is only applied to the second test. tests, whereas the "bar" mark is only applied to the second test.
Skip and xfail marks can also be applied in this way, see :ref:`skip/xfail with parametrize`. Skip and xfail marks can also be applied in this way, see :ref:`skip/xfail with parametrize`.
.. note::
If the data you are parametrizing happen to be single callables, you need to be careful
when marking these items. ``pytest.mark.xfail(my_func)`` won't work because it's also the
signature of a function being decorated. To resolve this ambiguity, you need to pass a
reason argument:
``pytest.mark.xfail(func_bar, reason="Issue#7")``.
.. _`adding a custom marker from a plugin`: .. _`adding a custom marker from a plugin`:
Custom marker and command line option to control test runs Custom marker and command line option to control test runs