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
|
- In assertion rewriting mode on Python 2, fix the detection of coding
|
||||||
cookies. See issue #330.
|
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
|
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")
|
help="run tests even if they are marked xfail")
|
||||||
|
|
||||||
def pytest_configure(config):
|
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",
|
config.addinivalue_line("markers",
|
||||||
"skipif(condition): skip the given test function if eval(condition) "
|
"skipif(condition): skip the given test function if eval(condition) "
|
||||||
"results in a True value. Evaluation happens within the "
|
"results in a True value. Evaluation happens within the "
|
||||||
|
|
28
setup.py
28
setup.py
|
@ -1,6 +1,20 @@
|
||||||
import os, sys
|
import os, sys
|
||||||
from setuptools import setup, Command
|
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()
|
long_description = open("README.rst").read()
|
||||||
def main():
|
def main():
|
||||||
install_requires = ["py>=1.4.17"]
|
install_requires = ["py>=1.4.17"]
|
||||||
|
@ -20,22 +34,10 @@ def main():
|
||||||
author='Holger Krekel, Benjamin Peterson, Ronny Pfannschmidt, Floris Bruynooghe and others',
|
author='Holger Krekel, Benjamin Peterson, Ronny Pfannschmidt, Floris Bruynooghe and others',
|
||||||
author_email='holger at merlinux.eu',
|
author_email='holger at merlinux.eu',
|
||||||
entry_points= make_entry_points(),
|
entry_points= make_entry_points(),
|
||||||
|
classifiers=classifiers,
|
||||||
cmdclass = {'test': PyTest},
|
cmdclass = {'test': PyTest},
|
||||||
# the following should be enabled for release
|
# the following should be enabled for release
|
||||||
install_requires=install_requires,
|
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'],
|
packages=['_pytest', '_pytest.assertion'],
|
||||||
py_modules=['pytest'],
|
py_modules=['pytest'],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
|
|
@ -159,13 +159,14 @@ class TestXFail:
|
||||||
@pytest.mark.xfail
|
@pytest.mark.xfail
|
||||||
def test_func():
|
def test_func():
|
||||||
assert 0
|
assert 0
|
||||||
|
def test_func2():
|
||||||
|
pytest.xfail("hello")
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest("--runxfail")
|
result = testdir.runpytest("--runxfail")
|
||||||
assert result.ret == 1
|
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"*def test_func():*",
|
"*def test_func():*",
|
||||||
"*assert 0*",
|
"*assert 0*",
|
||||||
"*1 failed*",
|
"*1 failed*1 pass*",
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_xfail_evalfalse_but_fails(self, testdir):
|
def test_xfail_evalfalse_but_fails(self, testdir):
|
||||||
|
@ -261,10 +262,7 @@ class TestXFail:
|
||||||
"*reason:*hello*",
|
"*reason:*hello*",
|
||||||
])
|
])
|
||||||
result = testdir.runpytest(p, "--runxfail")
|
result = testdir.runpytest(p, "--runxfail")
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines("*1 pass*")
|
||||||
"*def test_this():*",
|
|
||||||
"*pytest.xfail*",
|
|
||||||
])
|
|
||||||
|
|
||||||
def test_xfail_imperative_in_setup_function(self, testdir):
|
def test_xfail_imperative_in_setup_function(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
|
@ -285,10 +283,10 @@ class TestXFail:
|
||||||
"*reason:*hello*",
|
"*reason:*hello*",
|
||||||
])
|
])
|
||||||
result = testdir.runpytest(p, "--runxfail")
|
result = testdir.runpytest(p, "--runxfail")
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines("""
|
||||||
"*def setup_function(function):*",
|
*def test_this*
|
||||||
"*pytest.xfail*",
|
*1 fail*
|
||||||
])
|
""")
|
||||||
|
|
||||||
def xtest_dynamic_xfail_set_during_setup(self, testdir):
|
def xtest_dynamic_xfail_set_during_setup(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
p = testdir.makepyfile("""
|
||||||
|
|
Loading…
Reference in New Issue