From 758b5e3511e8208b8c875cf2938c12c8dca37f4f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 5 Jul 2011 21:23:59 +0200 Subject: [PATCH] fix issue53: nose-style setup now called with the correct ordering --- CHANGELOG | 1 + _pytest/__init__.py | 2 +- _pytest/nose.py | 1 + setup.py | 2 +- testing/test_nose.py | 16 ++++++++++++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 207aa899e..e88387dc4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Changes between 2.0.3 and 2.1.0.DEV ---------------------------------------------- +- fix issue53 call nosestyle setup functions with correct ordering - fix issue58 and issue59: new assertion code fixes - merge Benjamin's assertionrewrite branch: now assertions for test modules on python 2.6 and above are done by rewriting diff --git a/_pytest/__init__.py b/_pytest/__init__.py index bb391d246..0d9a6e1ef 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.1.0.dev8' +__version__ = '2.1.0.dev9' diff --git a/_pytest/nose.py b/_pytest/nose.py index 2f90a93f8..5560e473d 100644 --- a/_pytest/nose.py +++ b/_pytest/nose.py @@ -13,6 +13,7 @@ def pytest_runtest_makereport(__multicall__, item, call): call.excinfo = call2.excinfo +@pytest.mark.trylast def pytest_runtest_setup(item): if isinstance(item, (pytest.Function)): if isinstance(item.parent, pytest.Generator): diff --git a/setup.py b/setup.py index 1f53be51f..58cffc71e 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.1.0.dev8', + version='2.1.0.dev9', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_nose.py b/testing/test_nose.py index 4ce7cdf76..ea35c222d 100644 --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -255,3 +255,19 @@ def test_nose_style_setup_teardown(testdir): result.stdout.fnmatch_lines([ "*2 passed*", ]) + +def test_nose_setup_ordering(testdir): + testdir.makepyfile(""" + def setup_module(mod): + mod.visited = True + + class TestClass: + def setup(self): + assert visited + def test_first(self): + pass + """) + result = testdir.runpytest() + result.stdout.fnmatch_lines([ + "*1 passed*", + ])