def test_exitWithDefinedCode(self):
        """
        L{task.react} forwards the exit code specified by the C{SystemExit}
        error returned by the passed function, if any.
        """
        def main(reactor):
            return defer.fail(SystemExit(23))
        r = _FakeReactor()
        exitError = self.assertRaises(
            SystemExit, task.react, main, [], _reactor=r)
        self.assertEqual(23, exitError.code)

        L{task.react} forwards the exit code specified by the C{SystemExit}
        error returned by the passed function, if any.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_task.py