def pytest_pyfunc_call(self, pyfuncitem): testfunction = pyfuncitem.obj if pyfuncitem._isyieldedfunction(): with wdb.trace(): testfunction(*pyfuncitem._args) else: funcargs = pyfuncitem.funcargs testargs = {} for arg in pyfuncitem._fixtureinfo.argnames: testargs[arg] = funcargs[arg] with wdb.trace(): testfunction(**testargs) # Avoid multiple test call return True
def trace_wsgi(environ, start_response): wdb = Wdb.get() wdb.closed = False appiter = None try: with trace(close_on_exit=True, under=self.app): appiter = self.app(environ, start_response) for item in appiter: yield item except Exception: exc_info = sys.exc_info() try: start_response('500 INTERNAL SERVER ERROR', [('Content-Type', 'text/html')]) except AssertionError: log.exception( 'Exception with wdb off and headers already set', exc_info=exc_info) yield '\n'.join(traceback.format_exception( *exc_info)).replace('\n', '\n<br>\n').encode('utf-8') else: yield _handle_off() finally: hasattr(appiter, 'close') and appiter.close() wdb.closed = False
def _wdb_execute(*args, **kwargs): from wdb import trace, Wdb if Wdb.enabled: wdb = Wdb.get() wdb.closed = False # Activate request ignores interesting = True if len(args) > 0 and isinstance(args[0], ErrorHandler): interesting = False elif (len(args) > 2 and isinstance(args[0], StaticFileHandler) and args[2] == 'favicon.ico'): interesting = False if Wdb.enabled and interesting: with trace(close_on_exit=True, under=under): old_execute(*args, **kwargs) else: old_execute(*args, **kwargs) # Close set_trace debuggers stop_trace(close_on_exit=True) if Wdb.enabled: # Reset closed state wdb.closed = False
def trace_wsgi(environ, start_response): wdb = Wdb.get() wdb.closed = False appiter = None try: with trace(close_on_exit=True, under=self.app): appiter = self.app(environ, start_response) for item in appiter: yield item except Exception: exc_info = sys.exc_info() try: start_response( '500 INTERNAL SERVER ERROR', [('Content-Type', 'text/html')] ) except AssertionError: log.exception( 'Exception with wdb off and headers already set', exc_info=exc_info ) yield '\n'.join(traceback.format_exception(*exc_info) ).replace('\n', '\n<br>\n').encode('utf-8') else: yield _handle_off() finally: hasattr(appiter, 'close') and appiter.close() wdb.closed = False
def _wdb_execute(*args, **kwargs): from wdb import trace, Wdb if Wdb.enabled: with trace(close_on_exit=True, below=below, under=under): old_execute(*args, **kwargs) else: old_execute(*args, **kwargs) # Close set_trace debuggers stop_trace(close_on_exit=True)
def _wdb_execute(self, transforms): from wdb import trace, Wdb if Wdb.enabled: with trace(close_on_exit=True, below=True): old_execute(self, transforms) else: old_execute(self, transforms) # Close set_trace debuggers stop_trace(close_on_exit=True)
def trace_wsgi(environ, start_response): appiter = None try: with trace(close_on_exit=True): appiter = self.app(environ, start_response) for item in appiter: yield item except Exception: start_response('500 INTERNAL SERVER ERROR', [ ('Content-Type', 'text/html')]) yield _handle_off(self.theme) finally: hasattr(appiter, 'close') and appiter.close()
def trace_wsgi(environ, start_response): appiter = None try: with trace(close_on_exit=True): appiter = self.app(environ, start_response) for item in appiter: yield item except Exception: start_response('500 INTERNAL SERVER ERROR', [('Content-Type', 'text/html')]) yield _handle_off() finally: hasattr(appiter, 'close') and appiter.close()
def _wdb_execute(*args, **kwargs): from wdb import trace, Wdb interesting = True if len(args) > 0 and isinstance(args[0], ErrorHandler): interesting = False elif len(args) > 2 and isinstance( args[0], StaticFileHandler) and args[2] == 'favicon.ico': interesting = False if Wdb.enabled and interesting: with trace(close_on_exit=True, under=under): old_execute(*args, **kwargs) else: old_execute(*args, **kwargs) # Close set_trace debuggers stop_trace(close_on_exit=True)
def trace(self): trace(sys._getframe().f_back)
def uninteresting_function_catching(below): try: b = uncatched_exception(below) except ZeroDivisionError: b = 2 return b def one_more_step(fun, below): return fun(below) # This should not stop with trace(under=uninteresting_function): try: raise Exception('Catched Exception') except Exception: pass # This should not stop with trace(under=uninteresting_function): uninteresting_function(1) # This should stop # below = 1 the exception in catched exception should stop trace with trace(under=uninteresting_function_not_catching): try: uninteresting_function_not_catching(1) except:
def uninteresting_function_catching(below): try: b = uncatched_exception(below) except ZeroDivisionError: b = 2 return b def one_more_step(fun, below): return fun(below) # This should not stop # below = 1 so in trace exception should be ignored with trace(below=1): try: raise Exception('Catched Exception') except Exception: pass # This should not stop # below = 1 so catched function 2 layer under are ignored with trace(below=1): uninteresting_function(1) # This should stop # below = 1 the exception in catched exception should stop trace with trace(below=1): try: uninteresting_function_not_catching(1)
try: return i / 0 except ZeroDivisionError: return 2 def make_error_in_lib(): import os.path try: os.path.join(42, 42) except AttributeError: return True with trace(): a = 2 b = 4 c = a + b print(c) d = make_error(c) print(d) with trace(): make_error_in_lib() with trace(full=True): make_error_in_lib() print("The end")
def make_error(i): try: return i / 0 except ZeroDivisionError: return 2 def make_error_in_lib(): import os.path try: os.path.join(42, 42) except AttributeError: return True with trace(): a = 2 b = 4 c = a + b print(c) d = make_error(c) print(d) with trace(): make_error_in_lib() with trace(full=True): make_error_in_lib() print('The end')