Ejemplo n.º 1
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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 5
0
Archivo: ext.py Proyecto: 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
Ejemplo n.º 6
0
Archivo: ext.py Proyecto: 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)
Ejemplo n.º 7
0
Archivo: ext.py Proyecto: 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 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)
Ejemplo n.º 10
0
 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()
Ejemplo n.º 11
0
Archivo: ext.py Proyecto: 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()
Ejemplo n.º 12
0
Archivo: ext.py Proyecto: 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)
Ejemplo n.º 13
0
Archivo: ext.py Proyecto: minisin/wdb
 def trace(self):
     trace(sys._getframe().f_back)
Ejemplo n.º 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:
Ejemplo n.º 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)
Ejemplo n.º 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:
Ejemplo n.º 17
0
Archivo: ext.py Proyecto: niziou/wdb
 def trace(self):
     trace(sys._getframe().f_back)
Ejemplo n.º 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)
Ejemplo n.º 19
0
    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")
Ejemplo n.º 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')