[issue10611] sys.exit() in a test causes the run to stp

Michael Foord report at bugs.python.org
Fri Dec 3 02:25:19 CET 2010


New submission from Michael Foord <michael at voidspace.org.uk>:

Reported by a unittest2 user. 

A SystemExit (or GeneratorExit) will cause a test run to stop in 2.7 / 3.2. This would just be reported as an error in 2.6.

>>> from unittest import TestCase
>>> def test(s):
...  raise GeneratorExit
... 
>>> class T(TestCase):
...  test = test
... 
>>> t = T('test')
>>> t.run()


Above code works in Python 2.6 (the exception is caught by TestCase.run) but dies in 2.7 / 3.2

----------
assignee: michael.foord
keywords: easy
messages: 123153
nosy: michael.foord
priority: normal
severity: normal
stage: unit test needed
status: open
title: sys.exit() in a test causes the run to stp
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10611>
_______________________________________


More information about the Python-bugs-list mailing list