'Sets the Client to appear as if it has successfully logged into a site.
Returns True if login is possible; False if the provided credentials
are incorrect, or the user is inactive, or if the sessions framework is
not available.'

def login(self, **credentials):

    user = authenticate(**credentials)
    if (user and user.is_active and ('django.contrib.sessions' in settings.INSTALLED_APPS)):
        engine = import_module(settings.SESSION_ENGINE)
        request = HttpRequest()
        if self.session:
            request.session = self.session
        else:
            request.session = engine.SessionStore()
        login(request, user)
        request.session.save()
        session_cookie = settings.SESSION_COOKIE_NAME
        self.cookies[session_cookie] = request.session.session_key
        cookie_data = {'max-age': None, 'path': '/', 'domain': settings.SESSION_COOKIE_DOMAIN, 'secure': (settings.SESSION_COOKIE_SECURE or None), 'expires': None}
        self.cookies[session_cookie].update(cookie_data)
        return True
    else:
        return False
