예제 #1
0
파일: pytest_wdb.py 프로젝트: apriljdai/wdb
    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
예제 #2
0
    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
예제 #3
0
 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
예제 #4
0
    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
예제 #5
0
파일: ext.py 프로젝트: Kozea/wdb
 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
예제 #6
0
파일: ext.py 프로젝트: kaka19ace/wdb
 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)
예제 #7
0
파일: ext.py 프로젝트: rayleyva/wdb
 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)
예제 #8
0
파일: ext.py 프로젝트: cybernetics/wdb
 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)
예제 #9
0
 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)
예제 #10
0
파일: ext.py 프로젝트: cybernetics/wdb
 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()
예제 #11
0
파일: ext.py 프로젝트: rayleyva/wdb
 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()
예제 #12
0
파일: ext.py 프로젝트: s0undt3ch/wdb
    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)
예제 #13
0
파일: ext.py 프로젝트: minisin/wdb
 def trace(self):
     trace(sys._getframe().f_back)
예제 #14
0

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:
예제 #15
0
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)
예제 #16
0

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:
예제 #17
0
파일: ext.py 프로젝트: niziou/wdb
 def trace(self):
     trace(sys._getframe().f_back)
예제 #18
0
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)
예제 #19
0
파일: error_in_with.py 프로젝트: TFenby/wdb
    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")
예제 #20
0

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')