File tree 4 files changed +32
-2
lines changed 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -142,5 +142,6 @@ Trevor Bekolay
142
142
Tyler Goodlet
143
143
Vasily Kuznetsov
144
144
Victor Uriarte
145
+ Vidar T. Fauske
145
146
Wouter van Ackooy
146
147
Xuecong Liao
Original file line number Diff line number Diff line change 6
6
* Replace ``raise StopIteration `` usages in the code by simple ``returns `` to finish generators, in accordance to `PEP-479 `_ (`#2160 `_).
7
7
Thanks `@tgoodlet `_ for the report and `@nicoddemus `_ for the PR.
8
8
9
- *
9
+ * Skipping plugin now also works with test items generated by custom collectors (`#2231 `_).
10
+ Thanks to `@vidartf `_.
10
11
11
12
* Conditionless ``xfail `` markers no longer rely on the underlying test item
12
13
being an instance of ``PyobjMixin ``, and can therefore apply to tests not
19
20
20
21
.. _PEP-479 : https://www.python.org/dev/peps/pep-0479/
21
22
23
+ .. _#2231 : https://github.com/pytest-dev/pytest/issues/2231
24
+
25
+ .. _@vidartf : https://github.com/vidartf
26
+
22
27
23
28
3.0.6 (2017-01-22)
24
29
==================
Original file line number Diff line number Diff line change @@ -112,7 +112,8 @@ def istrue(self):
112
112
113
113
def _getglobals (self ):
114
114
d = {'os' : os , 'sys' : sys , 'config' : self .item .config }
115
- d .update (self .item .obj .__globals__ )
115
+ if hasattr (self .item , 'obj' ):
116
+ d .update (self .item .obj .__globals__ )
116
117
return d
117
118
118
119
def _istrue (self ):
Original file line number Diff line number Diff line change @@ -969,3 +969,26 @@ def test_func():
969
969
result .stdout .fnmatch_lines (
970
970
"*Using pytest.skip outside of a test is not allowed*"
971
971
)
972
+
973
+
974
+ def test_mark_xfail_item (testdir ):
975
+ # Ensure pytest.mark.xfail works with non-Python Item
976
+ testdir .makeconftest ("""
977
+ import pytest
978
+
979
+ class MyItem(pytest.Item):
980
+ nodeid = 'foo'
981
+ def setup(self):
982
+ marker = pytest.mark.xfail(True, reason="Expected failure")
983
+ self.add_marker(marker)
984
+ def runtest(self):
985
+ assert False
986
+
987
+ def pytest_collect_file(path, parent):
988
+ return MyItem("foo", parent)
989
+ """ )
990
+ result = testdir .inline_run ()
991
+ passed , skipped , failed = result .listoutcomes ()
992
+ assert not failed
993
+ xfailed = [r for r in skipped if hasattr (r , 'wasxfail' )]
994
+ assert xfailed
You can’t perform that action at this time.
0 commit comments