我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用exceptions.SystemExit()。
def handle_with_processors(self): def process(processors): try: if processors: p, processors = processors[0], processors[1:] return p(lambda: process(processors)) else: return self.handle() except web.HTTPError: raise except (KeyboardInterrupt, SystemExit): raise except: print >> web.debug, traceback.format_exc() raise self.internalerror() # processors must be applied in the resvere order. (??) return process(self.processors)
def test_create_deck_not_found(self): global_options = { 'no-yamloo': True, 'subargs': [], 'annotations': {}, 'collector': None, 'bouncer': None, 'no-collector': False, 'test_file': 'invalid/path', 'testdeck': None } exc = None try: createDeck(global_options) except exceptions.SystemExit as exc: exc = exc self.assertIsNotNone(exc) self.assertEqual(exc.code, 3)