当前位置: 首页>>代码示例>>Python>>正文


Python bdb.BdbQuit方法代码示例

本文整理汇总了Python中bdb.BdbQuit方法的典型用法代码示例。如果您正苦于以下问题:Python bdb.BdbQuit方法的具体用法?Python bdb.BdbQuit怎么用?Python bdb.BdbQuit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bdb的用法示例。


在下文中一共展示了bdb.BdbQuit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_exceptions

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def handle_exceptions(func: Callable, logger: Any, with_debugger: bool) -> Callable:
    """Drops a user into an interactive debugger if func raises an error."""

    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except (BdbQuit, KeyboardInterrupt):
            raise
        except Exception as e:
            logger.exception("Uncaught exception {}".format(e))
            if with_debugger:
                import pdb
                import traceback
                traceback.print_exc()
                pdb.post_mortem()
            else:
                raise

    return wrapped 
开发者ID:ihmeuw,项目名称:vivarium,代码行数:22,代码来源:utilities.py

示例2: test_BdbQuit

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def test_BdbQuit(testdir):
    testdir.makepyfile(
        test_foo="""
        import unittest

        class MyTestCase(unittest.TestCase):
            def test_bdbquit(self):
                import bdb
                raise bdb.BdbQuit()

            def test_should_not_run(self):
                pass
    """
    )
    reprec = testdir.inline_run()
    reprec.assertoutcome(failed=1, passed=1) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:18,代码来源:test_unittest.py

示例3: test_pdb_set_trace_interception

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def test_pdb_set_trace_interception(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pdb
            def test_1():
                pdb.set_trace()
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.expect("Pdb")
        child.sendline("q")
        rest = child.read().decode("utf8")
        assert "no tests ran" in rest
        assert "reading from stdin while output" not in rest
        assert "BdbQuit" not in rest
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:19,代码来源:test_debugging.py

示例4: test_doctest_set_trace_quit

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def test_doctest_set_trace_quit(self, testdir):
        p1 = testdir.makepyfile(
            """
            def function_1():
                '''
                >>> __import__('pdb').set_trace()
                '''
        """
        )
        # NOTE: does not use pytest.set_trace, but Python's patched pdb,
        #       therefore "-s" is required.
        child = testdir.spawn_pytest("--doctest-modules --pdb -s %s" % p1)
        child.expect("Pdb")
        child.sendline("q")
        rest = child.read().decode("utf8")

        assert "! _pytest.outcomes.Exit: Quitting debugger !" in rest
        assert "= no tests ran in" in rest
        assert "BdbQuit" not in rest
        assert "UNEXPECTED EXCEPTION" not in rest 
开发者ID:pytest-dev,项目名称:pytest,代码行数:22,代码来源:test_debugging.py

示例5: test_raises_bdbquit_with_eoferror

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def test_raises_bdbquit_with_eoferror(testdir):
    """It is not guaranteed that DontReadFromInput's read is called."""

    p1 = testdir.makepyfile(
        """
        def input_without_read(*args, **kwargs):
            raise EOFError()

        def test(monkeypatch):
            import builtins
            monkeypatch.setattr(builtins, "input", input_without_read)
            __import__('pdb').set_trace()
        """
    )
    result = testdir.runpytest(str(p1))
    result.stdout.fnmatch_lines(["E *BdbQuit", "*= 1 failed in*"])
    assert result.ret == 1 
开发者ID:pytest-dev,项目名称:pytest,代码行数:19,代码来源:test_debugging.py

示例6: trace_dispatch

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def trace_dispatch(self, stackframe, event, arg):
        """
        Trace function that does some preliminary checks and then defers to
        the event handler for each type of event.
        """
        if self.quitting:
            # We were told to quit by the user, bubble this up to their code.
            return

        if self.skip_fn(stackframe.f_code.co_filename):
            # We want to skip this, don't stop but keep tracing.
            return self.trace_dispatch

        try:
            return self.super_.trace_dispatch(stackframe, event, arg)
        except BdbQuit:
            raise QdbQuit()  # Rewrap as a QdbError object. 
开发者ID:quantopian,项目名称:qdb,代码行数:19,代码来源:tracer.py

示例7: boto_except_hook

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def boto_except_hook(debugger_flag, debug_flag):
    def excepthook(typ, value, tb):
        if typ is bdb.BdbQuit:
            sys.exit(1)
        sys.excepthook = sys.__excepthook__

        if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty():
            if debugger.__name__ == 'epdb':
                debugger.post_mortem(tb, typ, value)
            else:
                debugger.post_mortem(tb)
        elif debug_flag:
            print(traceback.print_tb(tb))
            sys.exit(1)
        else:
            print(value)
            sys.exit(1)

    return excepthook 
开发者ID:VirtueSecurity,项目名称:aws-extender,代码行数:21,代码来源:awsqueryrequest.py

示例8: boto_except_hook

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def boto_except_hook(debugger_flag, debug_flag):
    def excepthook(typ, value, tb):
        if typ is bdb.BdbQuit:
            sys.exit(1)
        sys.excepthook = sys.__excepthook__

        if debugger_flag and sys.stdout.isatty() and sys.stdin.isatty():
            if debugger.__name__ == 'epdb':
                debugger.post_mortem(tb, typ, value)
            else:
                debugger.post_mortem(tb)
        elif debug_flag:
            print traceback.print_tb(tb)
            sys.exit(1)
        else:
            print value
            sys.exit(1)

    return excepthook 
开发者ID:canvasnetworks,项目名称:canvas,代码行数:21,代码来源:awsqueryrequest.py

示例9: _debug_recipe

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def _debug_recipe(recipe_deps, recipe, test_data):
  """Debugs the given recipe + test case.

  Args:

    * recipe_deps (RecipeDeps)
    * recipe (Recipe)
    * test_data (TestData)
  """
  debugger = pdb.Pdb()
  for func in [recipe.global_symbols['RunSteps']]:
    debugger.set_break(
        func.func_code.co_filename,
        func.func_code.co_firstlineno,
        funcname=func.func_code.co_name)

  try:
    def dispatch_thunk(frame, event, arg):
      """Triggers 'continue' command when debugger starts."""
      val = debugger.trace_dispatch(frame, event, arg)
      debugger.set_continue()
      sys.settrace(debugger.trace_dispatch)
      return val
    debugger.reset()
    sys.settrace(dispatch_thunk)
    try:
      execute_test_case(recipe_deps, recipe.name, test_data)
    finally:
      debugger.quitting = 1
      sys.settrace(None)
  except bdb.BdbQuit:
    pass
  except Exception:  # pylint: disable=broad-except
    traceback.print_exc()
    print 'Uncaught exception. Entering post mortem debugging'
    print 'Running \'cont\' or \'step\' will restart the program'
    tback = sys.exc_info()[2]
    debugger.interaction(None, tback) 
开发者ID:luci,项目名称:recipes-py,代码行数:40,代码来源:debug.py

示例10: _handle_early_exits

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def _handle_early_exits(self, exc):
        """Handle some special cases for the exception hook.

        Return value:
            True: Exception hook should be aborted.
            False: Continue handling exception.
        """
        exctype, _excvalue, tb = exc

        if not self._quitter.quit_status['crash']:
            log.misc.error("ARGH, there was an exception while the crash "
                           "dialog is already shown:", exc_info=exc)
            return True

        log.misc.error("Uncaught exception", exc_info=exc)

        is_ignored_exception = (exctype is bdb.BdbQuit or
                                not issubclass(exctype, Exception))

        if 'pdb-postmortem' in objects.debug_flags:
            if tb is None:
                pdb.set_trace()  # noqa: T100
            else:
                pdb.post_mortem(tb)

        if is_ignored_exception or 'pdb-postmortem' in objects.debug_flags:
            # pdb exit, KeyboardInterrupt, ...
            sys.exit(usertypes.Exit.exception)

        if threading.current_thread() != threading.main_thread():
            log.misc.error("Ignoring exception outside of main thread... "
                           "Please report this as a bug.")
            return True

        return False 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:37,代码来源:crashsignal.py

示例11: check_interactive_exception

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def check_interactive_exception(call, report):
    return call.excinfo and not (
        hasattr(report, "wasxfail")
        or call.excinfo.errisinstance(Skipped)
        or call.excinfo.errisinstance(bdb.BdbQuit)
    ) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:8,代码来源:runner.py

示例12: run

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def run(self, cmd,globals=None, locals=None, start_stepping = 1):
		if type(cmd) not in [types.StringType, types.CodeType]:
			raise TypeError("Only strings can be run")
		self.last_cmd_debugged = cmd
		if start_stepping:
			self.isInitialBreakpoint = 0
		else:
			self.isInitialBreakpoint = 1
		try:
			if globals is None:
				import __main__
				globals = __main__.__dict__
			if locals is None:
				locals = globals
			self.reset()
			self.prep_run(cmd)
			sys.settrace(self.trace_dispatch)
			if type(cmd) != types.CodeType:
				cmd = cmd+'\n'
			try:
				try:
					if start_stepping: self.skipBotFrame = SKIP_STEP
					else: self.skipBotFrame = SKIP_RUN
					if sys.version_info > (2,2):
						exec cmd in globals, locals
					else:
						_doexec(cmd, globals, locals)
				except bdb.BdbQuit:
					pass
			finally:
				self.skipBotFrame = SKIP_NONE
				self.quitting = 1
				sys.settrace(None)

		finally:
			self.done_run(cmd) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:38,代码来源:debugger.py

示例13: runexec

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def runexec(self, what, globs=None, locs=None):
		self.reset()
		sys.settrace(self.trace_dispatch)
		try:
			try:
				exec what in globs, locs
			except bdb.BdbQuit:
				pass
		finally:
			self.quitting = 1
			sys.settrace(None) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:debugger.py

示例14: BdbQuit_excepthook

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def BdbQuit_excepthook(et, ev, tb, excepthook=None):
    """Exception hook which handles `BdbQuit` exceptions.

    All other exceptions are processed using the `excepthook`
    parameter.
    """
    if et==bdb.BdbQuit:
        print('Exiting Debugger.')
    elif excepthook is not None:
        excepthook(et, ev, tb)
    else:
        # Backwards compatibility. Raise deprecation warning?
        BdbQuit_excepthook.excepthook_ori(et,ev,tb) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:debugger.py

示例15: check_interactive_exception

# 需要导入模块: import bdb [as 别名]
# 或者: from bdb import BdbQuit [as 别名]
def check_interactive_exception(call: "CallInfo", report: BaseReport) -> bool:
    return call.excinfo is not None and not (
        hasattr(report, "wasxfail")
        or call.excinfo.errisinstance(Skipped)
        or call.excinfo.errisinstance(bdb.BdbQuit)
    ) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:8,代码来源:runner.py


注:本文中的bdb.BdbQuit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。