fix issue177 - actually perform session scope finalization

This commit is contained in:
holger krekel 2012-02-01 08:52:34 -05:00
parent 5263656df6
commit dfa273dc25
4 changed files with 23 additions and 3 deletions

View File

@ -1,2 +1,2 @@
# #
__version__ = '2.2.2.dev6' __version__ = '2.2.2.dev7'

View File

@ -47,6 +47,8 @@ def pytest_terminal_summary(terminalreporter):
def pytest_sessionstart(session): def pytest_sessionstart(session):
session._setupstate = SetupState() session._setupstate = SetupState()
def pytest_sessionfinish(session):
session._setupstate.teardown_all()
class NodeInfo: class NodeInfo:
def __init__(self, location): def __init__(self, location):

View File

@ -17,14 +17,14 @@ Bugs and issues: http://bitbucket.org/hpk42/pytest/issues/
Web page: http://pytest.org Web page: http://pytest.org
(c) Holger Krekel and others, 2004-2011 (c) Holger Krekel and others, 2004-2012
""" """
def main(): def main():
setup( setup(
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.2.2.dev6', version='2.2.2.dev7',
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

@ -1551,3 +1551,21 @@ def test_unorderable_types(testdir):
result = testdir.runpytest() result = testdir.runpytest()
assert "TypeError" not in result.stdout.str() assert "TypeError" not in result.stdout.str()
assert result.ret == 0 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*",
])