summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-10-09 22:55:20 +0200
committerholger krekel <holger@merlinux.eu>2013-10-09 22:55:20 +0200
commita5d4c2090581cbbdda641cd1b9cf9d2615b37534 (patch)
tree91c1fdbb290442cb51bbcc3832af1063ea6704bd
parent0335c6d7509daa16c174a02d864479b44356d8ce (diff)
downloadpytest-a5d4c2090581cbbdda641cd1b9cf9d2615b37534.tar.gz
make "--runxfail" turn imperative pytest.xfail calls into no ops
(it already did neutralize pytest.mark.xfail markers)
-rw-r--r--CHANGELOG3
-rw-r--r--_pytest/skipping.py8
-rw-r--r--setup.py28
-rw-r--r--testing/test_skipping.py18
4 files changed, 34 insertions, 23 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 042a4d3b2..ea8ee1af7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
-----------------------------------
diff --git a/_pytest/skipping.py b/_pytest/skipping.py
index d691d9fd8..f6915d431 100644
--- a/_pytest/skipping.py
+++ b/_pytest/skipping.py
@@ -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 "
diff --git a/setup.py b/setup.py
index ed7df7ecd..6e601d9ee 100644
--- a/setup.py
+++ b/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,
diff --git a/testing/test_skipping.py b/testing/test_skipping.py
index a3074b191..d22c45401 100644
--- a/testing/test_skipping.py
+++ b/testing/test_skipping.py
@@ -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("""