def _create_app(self): global GOLDEN_DB_URI _, self.working_database_path = tempfile.mkstemp(prefix='bookstore-', suffix='.sqlite') basedir = os.path.abspath(os.path.dirname(__file__)) os.environ["APP_CONFIG_PATH"] = os.path.join(basedir, 'conf', 'config_test.cfg') config.get_config().set( "storage", "connection", 'sqlite:///' + self.working_database_path) if not GOLDEN_DB_URI: storage.Base.metadata.create_all(tables._get_engine()) _, golden_database_path = tempfile.mkstemp(prefix='bookstore-', suffix='.sqlite') shutil.copyfile(self.working_database_path, golden_database_path) GOLDEN_DB_URI = golden_database_path else: shutil.copyfile(GOLDEN_DB_URI, self.working_database_path) self._app = create_app()