3 ms·
I'm guessing you mean like: def has_expired(now=None): #.. implementation instead of: def has_expired(): #.. implementation But at s
by meric 12y ago
I'm guessing you mean like:
def has_expired(now=None):
#.. implementation
instead of:
def has_expired():
#.. implementation
But at some point you need to call that method somewhere else...
def get_request_handler(request):
#...code
now = timezone.now()
if has_expired(now=now):
raise Error403.
And `get_request_handler` still needs to be tested, which I 'stub' the API for getting the current time in the correct timezone within the test for the request. (Taking into account the other comment), using a library called 'mock'. (https://pypi.python.org/pypi/mock https://pypi.python.org/pypi/mock)