Skip to content

Commit fece1fc

Browse files
add pytest.marked to mark documentation
1 parent d2c6564 commit fece1fc

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

doc/en/parametrize.rst

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ them in turn::
5656
$ pytest
5757
======= test session starts ========
5858
platform linux -- Python 3.5.2, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
59-
rootdir: $REGENDOC_TMPDIR, inifile:
59+
rootdir: $REGENDOC_TMPDIR, inifile:
6060
collected 3 items
61-
61+
6262
test_expectation.py ..F
63-
63+
6464
======= FAILURES ========
6565
_______ test_eval[6*9-42] ________
66-
66+
6767
test_input = '6*9', expected = 42
68-
68+
6969
@pytest.mark.parametrize("test_input,expected", [
7070
("3+5", 8),
7171
("2+4", 6),
@@ -75,7 +75,7 @@ them in turn::
7575
> assert eval(test_input) == expected
7676
E assert 54 == 42
7777
E + where 54 = eval('6*9')
78-
78+
7979
test_expectation.py:8: AssertionError
8080
======= 1 failed, 2 passed in 0.12 seconds ========
8181

@@ -94,21 +94,36 @@ for example with the builtin ``mark.xfail``::
9494
@pytest.mark.parametrize("test_input,expected", [
9595
("3+5", 8),
9696
("2+4", 6),
97-
pytest.mark.xfail(("6*9", 42)),
97+
pytest.marked(("6*9", 42), pytest.mark.xfail),
9898
])
9999
def test_eval(test_input, expected):
100100
assert eval(test_input) == expected
101101

102+
.. note::
103+
104+
prior to version 3.1 the supported mechanism for marking values
105+
used the syntax::
106+
107+
import pytest
108+
@pytest.mark.parametrize("test_input,expected", [
109+
("3+5", 8),
110+
("2+4", 6),
111+
pytest.mark.xfail(("6*9", 42),),
112+
])
113+
def test_eval(test_input, expected):
114+
assert eval(test_input) == expected
115+
116+
102117
Let's run this::
103118

104119
$ pytest
105120
======= test session starts ========
106121
platform linux -- Python 3.5.2, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
107-
rootdir: $REGENDOC_TMPDIR, inifile:
122+
rootdir: $REGENDOC_TMPDIR, inifile:
108123
collected 3 items
109-
124+
110125
test_expectation.py ..x
111-
126+
112127
======= 2 passed, 1 xfailed in 0.12 seconds ========
113128

114129
The one parameter set which caused a failure previously now
@@ -181,15 +196,15 @@ Let's also run with a stringinput that will lead to a failing test::
181196
F
182197
======= FAILURES ========
183198
_______ test_valid_string[!] ________
184-
199+
185200
stringinput = '!'
186-
201+
187202
def test_valid_string(stringinput):
188203
> assert stringinput.isalpha()
189204
E assert False
190205
E + where False = <built-in method isalpha of str object at 0xdeadbeef>()
191206
E + where <built-in method isalpha of str object at 0xdeadbeef> = '!'.isalpha
192-
207+
193208
test_strings.py:3: AssertionError
194209
1 failed in 0.12 seconds
195210

0 commit comments

Comments
 (0)