Ejemplo n.º 1
0
def failfast(method):
    def inner(self, *args, **kw):
        if getattr(self, 'failfast', False):
            self.stop()
        return method(self, *args, **kw)
    inner = wraps(method)(inner)
    return inner
Ejemplo n.º 2
0
def failfast(method):
    def inner(self, *args, **kw):
        if getattr(self, 'failfast', False):
            self.stop()
        return method(self, *args, **kw)

    inner = wraps(method)(inner)
    return inner
Ejemplo n.º 3
0
def expectedFailure(func):
    def wrapper(*args, **kwargs):
        try:
            func(*args, **kwargs)
        except Exception:
            raise _ExpectedFailure(sys.exc_info())
        raise _UnexpectedSuccess
    wrapper = wraps(func)(wrapper)
    return wrapper
Ejemplo n.º 4
0
def expectedFailure(func):
    def wrapper(*args, **kwargs):
        try:
            func(*args, **kwargs)
        except Exception:
            raise _ExpectedFailure(sys.exc_info())
        raise _UnexpectedSuccess

    wrapper = wraps(func)(wrapper)
    return wrapper
Ejemplo n.º 5
0
 def decorator(test_item):
     if not (isinstance(test_item, type) and issubclass(test_item, TestCase)):
         def skip_wrapper(*args, **kwargs):
             raise SkipTest(reason)
         skip_wrapper = wraps(test_item)(skip_wrapper)
         test_item = skip_wrapper
     
     test_item.__unittest_skip__ = True
     test_item.__unittest_skip_why__ = reason
     return test_item
Ejemplo n.º 6
0
    def decorator(test_item):
        if not (isinstance(test_item, type)
                and issubclass(test_item, TestCase)):

            def skip_wrapper(*args, **kwargs):
                raise SkipTest(reason)

            skip_wrapper = wraps(test_item)(skip_wrapper)
            test_item = skip_wrapper

        test_item.__unittest_skip__ = True
        test_item.__unittest_skip_why__ = reason
        return test_item
Ejemplo n.º 7
0
def removeHandler(method=None):
    if method is not None:
        def inner(*args, **kwargs):
            initial = signal.getsignal(signal.SIGINT)
            removeHandler()
            try:
                return method(*args, **kwargs)
            finally:
                signal.signal(signal.SIGINT, initial)
        inner = wraps(method)(inner)
        return inner

    global _interrupt_handler
    if _interrupt_handler is not None:
        signal.signal(signal.SIGINT, _interrupt_handler.default_handler)
Ejemplo n.º 8
0
def removeHandler(method=None):
    if method is not None:

        def inner(*args, **kwargs):
            initial = signal.getsignal(signal.SIGINT)
            removeHandler()
            try:
                return method(*args, **kwargs)
            finally:
                signal.signal(signal.SIGINT, initial)

        inner = wraps(method)(inner)
        return inner

    global _interrupt_handler
    if _interrupt_handler is not None:
        signal.signal(signal.SIGINT, _interrupt_handler.default_handler)
Ejemplo n.º 9
0
def emp_auth_needed(view_func):
    @login_required
    def _decorator(request, *args, **kwargs):
        # maybe do something before the view_func call
        if not request.user.is_authenticated():
            return HttpResponseRedirect('../../../login')
        try:
            emp = EmployeeInfo.objects.all().get(user=request.user)
        except EmployeeInfo.DoesNotExist:
            emp = None

        if emp is None:
            return HttpResponseForbidden()
        response = view_func(request, *args, **kwargs)
        # maybe do something after the view_func call
        return response

    return wraps(view_func)(_decorator)