Elffuss BraidHub

kikocis/auto-code-rover public

main · 22.2 KiBRawPermalink
1Pytest 6: Dynamically adding xfail marker in test no longer ignores failure
2<!--
3Thanks for submitting an issue!
4
5Here's a quick checklist for what to provide:
6-->
7
8## Description
9
10With pytest 5.x, we can dynamically add an xfail to a test `request` object using `request.node.add_marker(mark)` (see example below). In 5.x this treated the failing test like a a test marked statically with an `xfail`. With 6.0.0rc0 it raises.
11
12## Versions
13
14<details>
15
16```
17$ pip list
18Package Version Location
19----------------------------- ------------------------------- --------------------------------------------------------------
20a 1.0
21aioftp 0.13.0
22aiohttp 3.6.2
23alabaster 0.7.12
24apipkg 1.5
25aplus 0.11.0
26appdirs 1.4.3
27appnope 0.1.0
28arrow 0.15.7
29aspy.yaml 1.3.0
30astropy 3.2.3
31asv 0.4.1
32async-timeout 3.0.1
33atomicwrites 1.3.0
34attrs 19.1.0
35aws-sam-translator 1.15.1
36aws-xray-sdk 0.95
37Babel 2.7.0
38backcall 0.1.0
39binaryornot 0.4.4
40black 19.10b0
41bleach 3.1.0
42blurb 1.0.7
43bokeh 1.3.4
44boto 2.49.0
45boto3 1.7.84
46botocore 1.10.84
47bqplot 0.12.12
48branca 0.3.1
49cachetools 4.1.0
50certifi 2019.9.11
51cffi 1.13.2
52cfgv 2.0.1
53cfn-lint 0.25.0
54cftime 1.0.4.2
55chardet 3.0.4
56Click 7.0
57click-plugins 1.1.1
58cligj 0.5.0
59cloudpickle 1.2.2
60colorama 0.4.3
61colorcet 2.0.2
62coloredlogs 14.0
63cookiecutter 1.7.2
64cookies 2.2.1
65coverage 4.5.4
66cryptography 2.8
67cycler 0.10.0
68Cython 3.0a5
69cytoolz 0.10.1
70dask 2.4.0 /Users/taugspurger/Envs/pandas-dev/lib/python3.7/site-packages
71DateTime 4.3
72decorator 4.4.0
73defusedxml 0.6.0
74Deprecated 1.2.7
75distributed 2.4.0
76docker 4.1.0
77docutils 0.15.2
78ecdsa 0.14.1
79entrypoints 0.3
80et-xmlfile 1.0.1
81execnet 1.7.1
82fastparquet 0.3.3 /Users/taugspurger/sandbox/fastparquet
83feedparser 5.2.1
84Fiona 1.8.8
85flake8 3.7.9
86flake8-rst 0.7.1
87fletcher 0.3.1
88flit 2.1.0
89flit-core 2.1.0
90fsspec 0.7.4
91future 0.18.2
92gcsfs 0.6.2
93geopandas 0.6.0+1.g95b8e1a.dirty /Users/taugspurger/sandbox/geopandas
94gitdb2 2.0.5
95GitPython 3.0.2
96google-auth 1.16.1
97google-auth-oauthlib 0.4.1
98graphviz 0.13
99h5py 2.10.0
100HeapDict 1.0.1
101holoviews 1.12.6
102humanfriendly 8.1
103hunter 3.1.3
104hvplot 0.5.2
105hypothesis 4.36.2
106identify 1.4.7
107idna 2.8
108imagesize 1.1.0
109importlib-metadata 0.23
110importlib-resources 1.0.2
111iniconfig 1.0.0
112intake 0.5.3
113ipydatawidgets 4.0.1
114ipykernel 5.1.2
115ipyleaflet 0.13.0
116ipympl 0.5.6
117ipython 7.11.1
118ipython-genutils 0.2.0
119ipyvolume 0.5.2
120ipyvue 1.3.2
121ipyvuetify 1.4.0
122ipywebrtc 0.5.0
123ipywidgets 7.5.1
124isort 4.3.21
125jdcal 1.4.1
126jedi 0.16.0
127Jinja2 2.11.2
128jinja2-time 0.2.0
129jmespath 0.9.4
130joblib 0.14.1
131json5 0.9.4
132jsondiff 1.1.1
133jsonpatch 1.24
134jsonpickle 1.2
135jsonpointer 2.0
136jsonschema 3.0.2
137jupyter 1.0.0
138jupyter-client 5.3.3
139jupyter-console 6.0.0
140jupyter-core 4.5.0
141jupyterlab 2.1.2
142jupyterlab-server 1.1.4
143kiwisolver 1.1.0
144line-profiler 2.1.1
145llvmlite 0.33.0
146locket 0.2.0 /Users/taugspurger/sandbox/locket.py
147lxml 4.5.0
148manhole 1.6.0
149Markdown 3.1.1
150MarkupSafe 1.1.1
151matplotlib 3.2.2
152mccabe 0.6.1
153memory-profiler 0.55.0
154mistune 0.8.4
155mock 3.0.5
156more-itertools 7.2.0
157moto 1.3.6
158msgpack 0.6.2
159multidict 4.5.2
160munch 2.3.2
161mypy 0.730
162mypy-extensions 0.4.1
163nbconvert 5.6.0
164nbformat 4.4.0
165nbsphinx 0.4.2
166nest-asyncio 1.3.3
167nodeenv 1.3.3
168notebook 6.0.1
169numexpr 2.7.1
170numpy 1.19.0
171numpydoc 1.0.0.dev0
172oauthlib 3.1.0
173odfpy 1.4.0
174openpyxl 3.0.3
175packaging 20.4
176pandas 1.1.0.dev0+1758.g035e1fe831 /Users/taugspurger/sandbox/pandas
177pandas-sphinx-theme 0.0.1.dev0 /Users/taugspurger/sandbox/pandas-sphinx-theme
178pandocfilters 1.4.2
179param 1.9.2
180parfive 1.0.0
181parso 0.6.0
182partd 1.0.0
183pathspec 0.8.0
184patsy 0.5.1
185pexpect 4.7.0
186pickleshare 0.7.5
187Pillow 6.1.0
188pip 20.0.2
189pluggy 0.13.0
190poyo 0.5.0
191pre-commit 1.18.3
192progressbar2 3.51.3
193prometheus-client 0.7.1
194prompt-toolkit 2.0.9
195psutil 5.6.3
196ptyprocess 0.6.0
197py 1.9.0
198pyaml 20.4.0
199pyarrow 0.16.0
200pyasn1 0.4.7
201pyasn1-modules 0.2.8
202pycodestyle 2.5.0
203pycparser 2.19
204pycryptodome 3.9.8
205pyct 0.4.6
206pydata-sphinx-theme 0.1.1
207pydeps 1.9.0
208pyflakes 2.1.1
209PyGithub 1.44.1
210Pygments 2.4.2
211PyJWT 1.7.1
212pyparsing 2.4.2
213pyproj 2.4.0
214pyrsistent 0.15.4
215pytest 5.4.3
216pytest-asyncio 0.10.0
217pytest-cov 2.8.1
218pytest-cover 3.0.0
219pytest-forked 1.0.2
220pytest-repeat 0.8.0
221pytest-xdist 1.29.0
222python-boilerplate 0.1.0
223python-dateutil 2.8.0
224python-jose 2.0.2
225python-jsonrpc-server 0.3.2
226python-language-server 0.31.4
227python-slugify 4.0.1
228python-utils 2.4.0
229pythreejs 2.2.0
230pytoml 0.1.21
231pytz 2019.2
232pyviz-comms 0.7.2
233PyYAML 5.1.2
234pyzmq 18.1.0
235qtconsole 4.5.5
236regex 2020.6.8
237requests 2.24.0
238requests-oauthlib 1.3.0
239responses 0.10.6
240rsa 4.0
241rstcheck 3.3.1
242s3fs 0.4.2
243s3transfer 0.1.13
244scikit-learn 0.22.2.post1
245scipy 1.3.1
246seaborn 0.9.0
247Send2Trash 1.5.0
248setuptools 49.2.0
249Shapely 1.6.4.post2
250six 1.12.0
251smmap2 2.0.5
252snakeviz 2.0.1
253snowballstemmer 1.9.1
254sortedcontainers 2.1.0
255sparse 0.10.0
256Sphinx 3.1.1
257sphinxcontrib-applehelp 1.0.2
258sphinxcontrib-devhelp 1.0.2
259sphinxcontrib-htmlhelp 1.0.3
260sphinxcontrib-jsmath 1.0.1
261sphinxcontrib-qthelp 1.0.3
262sphinxcontrib-serializinghtml 1.1.4
263sphinxcontrib-websupport 1.1.2
264sphinxcontrib.youtube 0.1.2
265SQLAlchemy 1.3.11
266sshpubkeys 3.1.0
267statsmodels 0.10.2
268stdlib-list 0.6.0
269sunpy 1.1.dev518+gcad2d473f.d20191103 /Users/taugspurger/sandbox/sunpy
270tables 3.6.1
271tabulate 0.8.6
272tblib 1.4.0
273terminado 0.8.2
274test 1.0.0
275testpath 0.4.2
276text-unidecode 1.3
277thrift 0.13.0
278toml 0.10.0
279toolz 0.10.0
280tornado 6.0.3
281tqdm 4.37.0
282traitlets 4.3.2
283traittypes 0.2.1
284typed-ast 1.4.0
285typing-extensions 3.7.4
286ujson 1.35
287urllib3 1.25.5
288vaex 3.0.0
289vaex-arrow 0.5.1
290vaex-astro 0.7.0
291vaex-core 2.0.2
292vaex-hdf5 0.6.0
293vaex-jupyter 0.5.1.post0
294vaex-ml 0.9.0
295vaex-server 0.3.1
296vaex-viz 0.4.0
297virtualenv 16.7.5
298wcwidth 0.1.7
299webencodings 0.5.1
300websocket-client 0.56.0
301Werkzeug 0.16.0
302wheel 0.34.2
303widgetsnbextension 3.5.1
304wrapt 1.11.2
305xarray 0.14.1+36.gb3d3b448 /Users/taugspurger/sandbox/xarray
306xlwt 1.3.0
307xmltodict 0.12.0
308yarl 1.3.0
309zict 1.0.0
310zipp 0.6.0
311zope.interface 4.7.1
312```
313
314</details>
315
316- [ ] pytest and operating system versions
317
318Pytest 6.0.1rc0 and MacOS 10.14.5
319
320```python
321# file: test_foo.py
322import pytest
323
324
325def test_xfail_test(request):
326 mark = pytest.mark.xfail(reason="xfail")
327 request.node.add_marker(mark)
328 assert 0
329```
330
331With 5.4.3
332
333```
334
335$ pytest -rsx test_foo.py
336=============================================================================== test session starts ================================================================================
337platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.9.0, pluggy-0.13.0
338hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/taugspurger/sandbox/.hypothesis/examples')
339rootdir: /Users/taugspurger/sandbox
340plugins: xdist-1.29.0, hypothesis-4.36.2, forked-1.0.2, repeat-0.8.0, asyncio-0.10.0, cov-2.8.1
341collected 1 item
342
343test_foo.py x [100%]
344
345============================================================================= short test summary info ==============================================================================
346XFAIL test_foo.py::test_xfail_test
347 xfail
348================================================================================ 1 xfailed in 0.07s ================================================================================
349```
350
351With 6.0.0rc0
352
353```
354$ pytest -rsx test_foo.py
355=============================================================================== test session starts ================================================================================
356platform darwin -- Python 3.7.6, pytest-6.0.0rc1, py-1.9.0, pluggy-0.13.0
357hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/Users/taugspurger/sandbox/.hypothesis/examples')
358rootdir: /Users/taugspurger/sandbox
359plugins: xdist-1.29.0, hypothesis-4.36.2, forked-1.0.2, repeat-0.8.0, asyncio-0.10.0, cov-2.8.1
360collected 1 item
361
362test_foo.py F [100%]
363
364===================================================================================== FAILURES =====================================================================================
365_________________________________________________________________________________ test_xfail_test __________________________________________________________________________________
366
367request = <FixtureRequest for <Function test_xfail_test>>
368
369 def test_xfail_test(request):
370 mark = pytest.mark.xfail(reason="xfail")
371 request.node.add_marker(mark)
372> assert 0
373E assert 0
374
375test_foo.py:7: AssertionError
376```
377