Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: