text: import pytest
  
  from helloworld import app as _app
  from helloworld import db as _db
  
  TESTDB = 'test_helloworld.db'
  TESTDB_PATH = "/tmp/{}".format(TESTDB)
  TEST_DATABASE_URI = 'sqlite:///' + TESTDB_PATH
  
  
  @pytest.fixture(scope='session')
  def app(request):
      """Session-wide test `Flask` application."""
      _app.config['TESTING'] = True
      _app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
      return _app
  
  
  @pytest.fixture(scope='function')
  def db(request):
      def teardown():
          _db.session.remove()
          _db.drop_all()
  
      _db.create_all()
      request.addfinalizer(teardown)
      return _db
  
  
  @pytest.fixture(scope='function')
  def session(db, request):
      """Creates a new database session for a test."""
      connection = db.engine.connect()
      transaction = connection.begin()
  
      options = dict(bind=connection, binds={})
      session = db.create_scoped_session(options=options)
  
      db.session = session
  
      def teardown():
          transaction.rollback()
          connection.close()
          session.remove()
  
      request.addfinalizer(teardown)
      return session
  