我试图用Django做一些简单的测试,但是我不能成功地用这个用户登录。这是我的密码:
def createUser(isadmin):
u = User.objects.create_user(username="Test" + ("Admin" if isadmin else "Regular"), password="test")
return u
def loginUser(self, theusername, thepassword):
print(theusername + " " + thepassword)
a = self.client.login(username = theusername, password = thepassword)
# Prints false - should be true, right?
print(a)
之后的某个地方:
class DailyEntriesIntTests(TestCase):
def setUp(self):
self.client = Client()
u = createUser(False)
loginUser(self, u.username, u.password)
我登录不就需要这些吗?你知道吗
哎哟-密码是加密的-我需要传入明文密码,然后方法正确返回“true”。你知道吗
相关问题 更多 >
编程相关推荐