Merge pull request #2232 from vidartf/patch-1
Do not asssume `Item.obj` in 'skipping' plugin
This commit is contained in:
commit
ccf9877447
1
AUTHORS
1
AUTHORS
|
@ -142,5 +142,6 @@ Trevor Bekolay
|
||||||
Tyler Goodlet
|
Tyler Goodlet
|
||||||
Vasily Kuznetsov
|
Vasily Kuznetsov
|
||||||
Victor Uriarte
|
Victor Uriarte
|
||||||
|
Vidar T. Fauske
|
||||||
Wouter van Ackooy
|
Wouter van Ackooy
|
||||||
Xuecong Liao
|
Xuecong Liao
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to `PEP-479`_ (`#2160`_).
|
* Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to `PEP-479`_ (`#2160`_).
|
||||||
Thanks `@tgoodlet`_ for the report and `@nicoddemus`_ for the PR.
|
Thanks `@tgoodlet`_ for the report and `@nicoddemus`_ for the PR.
|
||||||
|
|
||||||
*
|
* Skipping plugin now also works with test items generated by custom collectors (`#2231`_).
|
||||||
|
Thanks to `@vidartf`_.
|
||||||
|
|
||||||
* Conditionless ``xfail`` markers no longer rely on the underlying test item
|
* Conditionless ``xfail`` markers no longer rely on the underlying test item
|
||||||
being an instance of ``PyobjMixin``, and can therefore apply to tests not
|
being an instance of ``PyobjMixin``, and can therefore apply to tests not
|
||||||
|
@ -19,6 +20,10 @@
|
||||||
|
|
||||||
.. _PEP-479: https://www.python.org/dev/peps/pep-0479/
|
.. _PEP-479: https://www.python.org/dev/peps/pep-0479/
|
||||||
|
|
||||||
|
.. _#2231: https://github.com/pytest-dev/pytest/issues/2231
|
||||||
|
|
||||||
|
.. _@vidartf: https://github.com/vidartf
|
||||||
|
|
||||||
|
|
||||||
3.0.6 (2017-01-22)
|
3.0.6 (2017-01-22)
|
||||||
==================
|
==================
|
||||||
|
|
|
@ -112,7 +112,8 @@ class MarkEvaluator:
|
||||||
|
|
||||||
def _getglobals(self):
|
def _getglobals(self):
|
||||||
d = {'os': os, 'sys': sys, 'config': self.item.config}
|
d = {'os': os, 'sys': sys, 'config': self.item.config}
|
||||||
d.update(self.item.obj.__globals__)
|
if hasattr(self.item, 'obj'):
|
||||||
|
d.update(self.item.obj.__globals__)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _istrue(self):
|
def _istrue(self):
|
||||||
|
|
|
@ -969,3 +969,26 @@ def test_module_level_skip_error(testdir):
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(
|
||||||
"*Using pytest.skip outside of a test is not allowed*"
|
"*Using pytest.skip outside of a test is not allowed*"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_mark_xfail_item(testdir):
|
||||||
|
# Ensure pytest.mark.xfail works with non-Python Item
|
||||||
|
testdir.makeconftest("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
class MyItem(pytest.Item):
|
||||||
|
nodeid = 'foo'
|
||||||
|
def setup(self):
|
||||||
|
marker = pytest.mark.xfail(True, reason="Expected failure")
|
||||||
|
self.add_marker(marker)
|
||||||
|
def runtest(self):
|
||||||
|
assert False
|
||||||
|
|
||||||
|
def pytest_collect_file(path, parent):
|
||||||
|
return MyItem("foo", parent)
|
||||||
|
""")
|
||||||
|
result = testdir.inline_run()
|
||||||
|
passed, skipped, failed = result.listoutcomes()
|
||||||
|
assert not failed
|
||||||
|
xfailed = [r for r in skipped if hasattr(r, 'wasxfail')]
|
||||||
|
assert xfailed
|
||||||
|
|
Loading…
Reference in New Issue