From dfa273dc2596645be45e3c58a0634d3ffd0ff6a2 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 1 Feb 2012 08:52:34 -0500 Subject: [PATCH] fix issue177 - actually perform session scope finalization --- _pytest/__init__.py | 2 +- _pytest/runner.py | 2 ++ setup.py | 4 ++-- testing/test_python.py | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 0a695c203..52b65015f 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.2.dev6' +__version__ = '2.2.2.dev7' diff --git a/_pytest/runner.py b/_pytest/runner.py index 048ca1dd9..f9f203ffa 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -47,6 +47,8 @@ def pytest_terminal_summary(terminalreporter): def pytest_sessionstart(session): session._setupstate = SetupState() +def pytest_sessionfinish(session): + session._setupstate.teardown_all() class NodeInfo: def __init__(self, location): diff --git a/setup.py b/setup.py index e28c8af9f..82930c9a8 100644 --- a/setup.py +++ b/setup.py @@ -17,14 +17,14 @@ Bugs and issues: http://bitbucket.org/hpk42/pytest/issues/ Web page: http://pytest.org -(c) Holger Krekel and others, 2004-2011 +(c) Holger Krekel and others, 2004-2012 """ def main(): setup( name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.2.2.dev6', + version='2.2.2.dev7', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_python.py b/testing/test_python.py index 9db9b446c..ad602d5a9 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -1551,3 +1551,21 @@ def test_unorderable_types(testdir): result = testdir.runpytest() assert "TypeError" not in result.stdout.str() assert result.ret == 0 + +def test_issue117_sessionscopeteardown(testdir): + testdir.makepyfile(""" + def pytest_funcarg__app(request): + app = request.cached_setup( + scope='session', + setup=lambda: 0, + teardown=lambda x: 3/x) + return app + def test_func(app): + pass + """) + result = testdir.runpytest() + assert result.ret != 0 + result.stderr.fnmatch_lines([ + "*3/x*", + "*ZeroDivisionError*", + ])