don't call nose' setup methods if they are marked with pytest.setup
This commit is contained in:
parent
738f14a48a
commit
465cfff6f9
|
@ -1,2 +1,2 @@
|
|||
#
|
||||
__version__ = '2.3.0.dev15'
|
||||
__version__ = '2.3.0.dev16'
|
||||
|
|
|
@ -41,7 +41,7 @@ def pytest_make_collect_report(collector):
|
|||
|
||||
def call_optional(obj, name):
|
||||
method = getattr(obj, name, None)
|
||||
if method:
|
||||
if method is not None and not hasattr(method, "_pytestsetup"):
|
||||
# If there's any problems allow the exception to raise rather than
|
||||
# silently ignoring them
|
||||
method()
|
||||
|
|
2
setup.py
2
setup.py
|
@ -24,7 +24,7 @@ def main():
|
|||
name='pytest',
|
||||
description='py.test: simple powerful testing with Python',
|
||||
long_description = long_description,
|
||||
version='2.3.0.dev15',
|
||||
version='2.3.0.dev16',
|
||||
url='http://pytest.org',
|
||||
license='MIT license',
|
||||
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
|
||||
|
|
|
@ -24,6 +24,17 @@ def test_nose_setup(testdir):
|
|||
])
|
||||
|
||||
|
||||
def test_setup_func_with_setup_decorator():
|
||||
from _pytest.nose import call_optional
|
||||
l = []
|
||||
class A:
|
||||
@pytest.setup()
|
||||
def f(self):
|
||||
l.append(1)
|
||||
call_optional(A(), "f")
|
||||
assert not l
|
||||
|
||||
|
||||
def test_nose_setup_func(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
from nose.tools import with_setup
|
||||
|
|
Loading…
Reference in New Issue