如何登录单元测试?

2024-04-26 13:11:08 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我试图用单元测试来测试我的应用程序,但是我的代码不起作用

def test_login(self):
    tester = app.test_client(self)
    response = tester.post('/login', data=dict(username="test", 
    password="test"), 
    follow_redirects=True)
    self.assertIn(b'Welcome to Website', response.data)

这给了我一个错误“self.assertIn(b'Welcome to Website',response.data)not found in b” 有什么建议吗


Tags: to代码testself应用程序dataresponsedef