@@ -56,16 +56,16 @@ them in turn::
56
56
$ pytest
57
57
======= test session starts ========
58
58
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:
60
60
collected 3 items
61
-
61
+
62
62
test_expectation.py ..F
63
-
63
+
64
64
======= FAILURES ========
65
65
_______ test_eval[6*9-42] ________
66
-
66
+
67
67
test_input = '6*9', expected = 42
68
-
68
+
69
69
@pytest.mark.parametrize("test_input,expected", [
70
70
("3+5", 8),
71
71
("2+4", 6),
@@ -75,7 +75,7 @@ them in turn::
75
75
> assert eval(test_input) == expected
76
76
E assert 54 == 42
77
77
E + where 54 = eval('6*9')
78
-
78
+
79
79
test_expectation.py:8: AssertionError
80
80
======= 1 failed, 2 passed in 0.12 seconds ========
81
81
@@ -94,21 +94,36 @@ for example with the builtin ``mark.xfail``::
94
94
@pytest.mark.parametrize("test_input,expected", [
95
95
("3+5", 8),
96
96
("2+4", 6),
97
- pytest.mark.xfail (("6*9", 42)),
97
+ pytest.marked (("6*9", 42), pytest.mark.xfail ),
98
98
])
99
99
def test_eval(test_input, expected):
100
100
assert eval(test_input) == expected
101
101
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
+
102
117
Let's run this::
103
118
104
119
$ pytest
105
120
======= test session starts ========
106
121
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:
108
123
collected 3 items
109
-
124
+
110
125
test_expectation.py ..x
111
-
126
+
112
127
======= 2 passed, 1 xfailed in 0.12 seconds ========
113
128
114
129
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::
181
196
F
182
197
======= FAILURES ========
183
198
_______ test_valid_string[!] ________
184
-
199
+
185
200
stringinput = '!'
186
-
201
+
187
202
def test_valid_string(stringinput):
188
203
> assert stringinput.isalpha()
189
204
E assert False
190
205
E + where False = <built-in method isalpha of str object at 0xdeadbeef>()
191
206
E + where <built-in method isalpha of str object at 0xdeadbeef> = '!'.isalpha
192
-
207
+
193
208
test_strings.py:3: AssertionError
194
209
1 failed in 0.12 seconds
195
210
0 commit comments