嗨,想在终端的烧瓶应用程序中测试“删除路线”,我可以看到测试已经过去,它说“test_user_delete (test_app.LayoutTestCase) ... ok”但是当我打开封面时它仍然是红色这意味着不包括它,请您向我解释为什么以及在哪里做错了?
app.layout.view.py
测试.py
e1 = Users(name='admine2', email='admine2@gmail.com', age=25)
e2 = Users(name='teste2', email='teste2@gmail.com', age=27)
db.session.add_all([e1, e2])
db.session.commit()
u = Users.query.get(1)
db.session.remove()
db.session.delete(u)
response = self.client.post('/delete/1',
follow_redirects=True)
self.assertTrue('admine2 is removed!', response.data)
视图.py:
@layout.route('/delete/<int:id>')
def delete(id):
"""remove monkey"""
user = Users.query.get_or_404(id)
db.session.delete(user)
db.session.commit()
flash("{0} is removed!".format(user.name))
return redirect(url_for("layout.user", page=1, sortby='normal'))