def client(): db_fd, minitwit.app.config['DATABASE'] = tempfile.mkstemp() client = minitwit.app.test_client() with minitwit.app.app_context(): minitwit.init_db() yield client os.close(db_fd) os.unlink(minitwit.app.config['DATABASE'])
def client(request): db_fd, minitwit.app.config['DATABASE'] = tempfile.mkstemp() client = minitwit.app.test_client() with minitwit.app.app_context(): minitwit.init_db() def teardown(): """Get rid of the database again after each test.""" os.close(db_fd) os.unlink(minitwit.app.config['DATABASE']) request.addfinalizer(teardown) return client
def setUp(self): """Before each test, set up a blank database""" self.db_fd, minitwit.app.config['DATABASE'] = tempfile.mkstemp() self.app = minitwit.app.test_client() minitwit.init_db()