I have unit test as
class TestUser(TestCase):
def setUp(self):
print 'setting db up'
db.create_all()
def test_new_user(self):
user = User('[email protected]', '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()
When I run this on command-line, I see
python -m unittest discover
secret key: test secret key
db url: postgresql+psycopg2://testuser:testpasswd@localhost/mydb
setting db up
destroying db
But it never comes out, keep on hanging, what is that I am doing wrong? I am new to unit testing in python and dont know how to test when I have to connect to database. Please advise