This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SystemExit in setUpClass etc. terminates test run
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexander.sturm, ezio.melotti, iritkatriel
Priority: normal Keywords: patch

Created on 2016-08-23 09:52 by alexander.sturm, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue_27835.diff alexander.sturm, 2016-08-23 09:54 possible patch against python 2.7 review
issue_27835_py3k.diff alexander.sturm, 2016-08-23 09:57 possible patch against py3k review
Messages (2)
msg273430 - (view) Author: (alexander.sturm) * Date: 2016-08-23 09:52
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
msg386838 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-02-11 22:51
I can't reproduce the issue. I think it was fixed in issue24412.
History
Date User Action Args
2022-04-11 14:58:35adminsetgithub: 72022
2021-04-16 18:52:57iritkatrielsetstatus: pending -> closed
stage: patch review -> resolved
2021-02-11 22:51:34iritkatrielsetstatus: open -> pending

nosy: + iritkatriel
messages: + msg386838

resolution: fixed
2016-08-24 07:16:52SilentGhostsetnosy: + ezio.melotti
stage: patch review

versions: + Python 3.6
2016-08-23 09:57:41alexander.sturmsetfiles: + issue_27835_py3k.diff
2016-08-23 09:54:34alexander.sturmsetfiles: + issue_27835.diff
keywords: + patch
2016-08-23 09:52:35alexander.sturmcreate