def __enter__(self):
    loginok = self.testcase.client.login(username=getattr(self.user, get_user_model().USERNAME_FIELD), password=getattr(self.user, get_user_model().USERNAME_FIELD))
    self.old_user = getattr(self.testcase, 'user', None)
    self.testcase.user = self.user
    self.testcase.assertTrue(loginok)
def __enter__(self):
    loginok = self.testcase.client.login(username=getattr(self.user, get_user_model().USERNAME_FIELD), password=getattr(self.user, get_user_model().USERNAME_FIELD))
    self.old_user = getattr(self.testcase, 'user', None)
    self.testcase.user = self.user
    self.testcase.assertTrue(loginok)