

def login(self, **credentials):
    'Log the user with the given credentials into your Django\n        site.\n\n        To further simplify things, rather than giving the credentials,\n        you may pass a ``user`` parameter with the ``User`` instance you\n        want to login. Note that in this case the user will not be\n        further validated, i.e. it is possible to login an inactive user\n        this way.\n\n        This works regardless of the url currently browsed, but does\n        require the WSGI intercept to be setup.\n\n        Returns ``True`` if login was possible; ``False`` if the\n        provided credentials are incorrect, or the user is inactive,\n        or if the sessions framework is not available.\n\n        Based on ``django.test.client.Client.logout``.\n\n        Note: A ``twill.reload()`` will not refresh the cookies sent\n        with the request, so your login will not have any effect there.\n        This is different for ``logout``, since it actually invalidates\n        the session server-side, thus making the current key invalid.\n        '
    if (not ('django.contrib.sessions' in settings.INSTALLED_APPS)):
        return False
    (host, port) = INSTALLED.keys()[(- 1)]
    user = credentials.pop('user', None)
    if user:
        backend = auth.get_backends()[0]
        user.backend = user.backend = ('%s.%s' % (backend.__module__, backend.__class__.__name__))
    else:
        user = auth.authenticate(**credentials)
        if ((not user) or (not user.is_active)):
            return False
    request = HttpRequest()
    request.session = __import__(settings.SESSION_ENGINE, {
        
    }, {
        
    }, ['']).SessionStore()
    auth.login(request, user)
    request.session.save()
    self.cj.set_cookie(cookielib.Cookie(version=None, name=settings.SESSION_COOKIE_NAME, value=request.session.session_key, port=str(port), port_specified=False, domain=host, domain_specified=True, domain_initial_dot=False, path='/', path_specified=True, secure=(settings.SESSION_COOKIE_SECURE or None), expires=None, discard=None, comment=None, comment_url=None, rest=None))
    return True

dataset/ETHPy150Open ericholscher/django-test-utils/test_utils/utils/twill_runner.py _EasyTwillBrowser.login/original