import pytest import sqlite3 from selenium import webdriver @pytest.fixture def URL(): return 'http://127.0.0.1:5000' # URL of the program @pytest.fixture def driver(): return webdriver.Edge() # uncomment this line if you wish to run the test on your laptop @pytest.fixture def UNAME(): return 'lanhui' @pytest.fixture def PASSWORD(): return 'l0ve1t' @pytest.fixture(autouse=True) def restore_sqlite_database(): ''' Automatically restore SQLite database file app/db/wordfreqapp.db using SQL statements from app/static/wordfreqapp.sql ''' con = sqlite3.connect('../db/wordfreqapp.db') with con: con.executescript('DROP TABLE IF EXISTS user;') con.executescript('DROP TABLE IF EXISTS article;') con.executescript(open('../static/wordfreqapp.sql', encoding='utf8').read()) con.close()