make "--runxfail" turn imperative pytest.xfail calls into no ops
(it already did neutralize pytest.mark.xfail markers)
This commit is contained in:
parent
0335c6d750
commit
a5d4c20905
|
@ -4,6 +4,9 @@ Changes between 2.4.2 and 2.4.3
|
|||
- In assertion rewriting mode on Python 2, fix the detection of coding
|
||||
cookies. See issue #330.
|
||||
|
||||
- make "--runxfail" turn imperative pytest.xfail calls into no ops
|
||||
(it already did neutralize pytest.mark.xfail markers)
|
||||
|
||||
Changes between 2.4.1 and 2.4.2
|
||||
-----------------------------------
|
||||
|
||||
|
|
|
@ -10,6 +10,14 @@ def pytest_addoption(parser):
|
|||
help="run tests even if they are marked xfail")
|
||||
|
||||
def pytest_configure(config):
|
||||
if config.option.runxfail:
|
||||
old = pytest.xfail
|
||||
config._cleanup.append(lambda: setattr(pytest, "xfail", old))
|
||||
def nop(*args, **kwargs):
|
||||
pass
|
||||
nop.Exception = XFailed
|
||||
setattr(pytest, "xfail", nop)
|
||||
|
||||
config.addinivalue_line("markers",
|
||||
"skipif(condition): skip the given test function if eval(condition) "
|
||||
"results in a True value. Evaluation happens within the "
|
||||
|
|
28
setup.py
28
setup.py
|
@ -1,6 +1,20 @@
|
|||
import os, sys
|
||||
from setuptools import setup, Command
|
||||
|
||||
classifiers=['Development Status :: 6 - Mature',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Topic :: Software Development :: Testing',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Utilities',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 3'] + [
|
||||
("Programming Language :: Python :: %s" % x) for x in
|
||||
"2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3".split()]
|
||||
|
||||
long_description = open("README.rst").read()
|
||||
def main():
|
||||
install_requires = ["py>=1.4.17"]
|
||||
|
@ -20,22 +34,10 @@ def main():
|
|||
author='Holger Krekel, Benjamin Peterson, Ronny Pfannschmidt, Floris Bruynooghe and others',
|
||||
author_email='holger at merlinux.eu',
|
||||
entry_points= make_entry_points(),
|
||||
classifiers=classifiers,
|
||||
cmdclass = {'test': PyTest},
|
||||
# the following should be enabled for release
|
||||
install_requires=install_requires,
|
||||
classifiers=['Development Status :: 6 - Mature',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: MIT License',
|
||||
'Operating System :: POSIX',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Topic :: Software Development :: Testing',
|
||||
'Topic :: Software Development :: Libraries',
|
||||
'Topic :: Utilities',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 3'] + [
|
||||
("Programming Language :: Python :: %s" % x) for x in
|
||||
"2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3".split()],
|
||||
packages=['_pytest', '_pytest.assertion'],
|
||||
py_modules=['pytest'],
|
||||
zip_safe=False,
|
||||
|
|
|
@ -159,13 +159,14 @@ class TestXFail:
|
|||
@pytest.mark.xfail
|
||||
def test_func():
|
||||
assert 0
|
||||
def test_func2():
|
||||
pytest.xfail("hello")
|
||||
""")
|
||||
result = testdir.runpytest("--runxfail")
|
||||
assert result.ret == 1
|
||||
result.stdout.fnmatch_lines([
|
||||
"*def test_func():*",
|
||||
"*assert 0*",
|
||||
"*1 failed*",
|
||||
"*1 failed*1 pass*",
|
||||
])
|
||||
|
||||
def test_xfail_evalfalse_but_fails(self, testdir):
|
||||
|
@ -261,10 +262,7 @@ class TestXFail:
|
|||
"*reason:*hello*",
|
||||
])
|
||||
result = testdir.runpytest(p, "--runxfail")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*def test_this():*",
|
||||
"*pytest.xfail*",
|
||||
])
|
||||
result.stdout.fnmatch_lines("*1 pass*")
|
||||
|
||||
def test_xfail_imperative_in_setup_function(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
|
@ -285,10 +283,10 @@ class TestXFail:
|
|||
"*reason:*hello*",
|
||||
])
|
||||
result = testdir.runpytest(p, "--runxfail")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*def setup_function(function):*",
|
||||
"*pytest.xfail*",
|
||||
])
|
||||
result.stdout.fnmatch_lines("""
|
||||
*def test_this*
|
||||
*1 fail*
|
||||
""")
|
||||
|
||||
def xtest_dynamic_xfail_set_during_setup(self, testdir):
|
||||
p = testdir.makepyfile("""
|
||||
|
|
Loading…
Reference in New Issue