Testing Python Decorators?

Posted by Jama22 on Stack Overflow See other posts from Stack Overflow or by Jama22
Published on 2010-04-29T15:35:56Z Indexed on 2010/04/29 15:37 UTC
Read the original article Hit count: 480

I'm writing some unit tests for a Django project, and I was wondering if its possible (or necessary?) to test some of the decorators that I wrote for it.

Here is an example of a decorator that I wrote:

class login_required(object):

def __init__(self, f):
    self.f = f

def __call__(self, *args):
    request = args[0]
    if request.user and request.user.is_authenticated():
        return self.f(*args)
    return redirect('/login')

© Stack Overflow or respective owner

Related posts about python

Related posts about django