forked from mrlan/EnglishPal
Define fixture 'restore_sqlite_database' that will be automatically used to restore the database before starting each test
parent
4f91659713
commit
77a3adb546
|
@ -1,4 +1,5 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
import sqlite3
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -9,3 +10,17 @@ def URL():
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def driver():
|
def driver():
|
||||||
return webdriver.Edge() # uncomment this line if you wish to run the test on your laptop
|
return webdriver.Edge() # uncomment this line if you wish to run the test on your laptop
|
||||||
|
|
||||||
|
|
||||||
|
@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()
|
||||||
|
|
Loading…
Reference in New Issue