[issue27835] SystemExit in setUpClass etc. terminates test run

alexander.sturm report at bugs.python.org
Tue Aug 23 05:52:35 EDT 2016


New submission from alexander.sturm:

In the following example code, a SystemExit is raised in setUpClass of a unittest.TestCase, which causes the python instance to terminate. This behavior is inconsistent with how SystemExit is handled in other places (e.g. in setUp/tearDown methods, or in actual test methods), where it is caught by unittest to prevent termination. See also issue #10611.

import unittest
class Test(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        raise SystemExit()

    def test_something(self):
        pass

result = unittest.TestResult()
suite = unittest.TestSuite()
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(Test))
suite.run(result)
print result

----------
components: Library (Lib)
messages: 273430
nosy: alexander.sturm
priority: normal
severity: normal
status: open
title: SystemExit in setUpClass etc. terminates test run
type: behavior
versions: Python 2.7, Python 3.5

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


More information about the Python-bugs-list mailing list