don't call nose' setup methods if they are marked with pytest.setup

This commit is contained in:
holger krekel 2012-09-22 00:23:36 +02:00
parent 738f14a48a
commit 465cfff6f9
4 changed files with 14 additions and 3 deletions

View File

@ -1,2 +1,2 @@
# #
__version__ = '2.3.0.dev15' __version__ = '2.3.0.dev16'

View File

@ -41,7 +41,7 @@ def pytest_make_collect_report(collector):
def call_optional(obj, name): def call_optional(obj, name):
method = getattr(obj, name, None) 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 # If there's any problems allow the exception to raise rather than
# silently ignoring them # silently ignoring them
method() method()

View File

@ -24,7 +24,7 @@ def main():
name='pytest', name='pytest',
description='py.test: simple powerful testing with Python', description='py.test: simple powerful testing with Python',
long_description = long_description, long_description = long_description,
version='2.3.0.dev15', version='2.3.0.dev16',
url='http://pytest.org', url='http://pytest.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -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): def test_nose_setup_func(testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
from nose.tools import with_setup from nose.tools import with_setup