【发布时间】:2014-10-27 22:13:35
【问题描述】:
我想在框架Flask中进行这样的测试并得到消息:
InvalidRequestError: Instance '<User at 0x7f65938a7510>' is not persisted
File "tests.py", line 31, in test_removeProfil
db.session.delete(user)
我的测试代码:
class TestCase(unittest.TestCase):
def test_removeProfil(self):
user = User(name="John", age=33, email="john@john.com")
db.session.delete(user)
db.session.commit()
self.assertNotEqual(user.name, "John")
self.assertNotEqual(user.age, 33)
self.assertNotEqual(user.email, "john@john.com")
【问题讨论】:
标签: python unit-testing flask