我有单元测试
class TestUser(TestCase):
def setUp(self):
print 'setting db up'
db.create_all()
def test_new_user(self):
user = User('test_new_user@none.com', 'welcome')
db.session.add(user)
db.session.commit()
users_in_db = User.query.all()
self.assertEquals(1, len(users_in_db))
self.assertEquals(user.email, users_in_db[0].email)
self.assertEquals(user._password, users_in_db[0]._password)
def tearDown(self):
print 'destroying db'
db.drop_all()
当我在命令行上运行它时,我看到
python -m unittest discover
secret key: test secret key
db url: postgresql+psycopg2://testuser:testpasswd@localhost/mydb
setting db up
destroying db
但它永远不会出来,继续挂,我做错了什么?我是 python 单元测试的新手,当我必须连接到数据库时不知道如何测试。请指教