tests and config for pytest and coverage

This commit is contained in:
2021-10-11 01:48:48 -06:00
parent 802418bdf5
commit ff3310f366
4 changed files with 62 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
import os
import tempfile
import pytest
from flaskfdx import create_app
from flaskfdx.db import get_db, init_db
with open(os.path.join(os.path.dirname(__file__), 'data.sql'), 'rb') as f:
_data_sql = f.read().decode('utf8')
@pytest.fixture
def app():
db_fd, db_path = tempfile.mkstemp()
app = create_app({
'TESTING': True,
'DATABASE': db_path,
})
with app.app_context():
init_db()
get_db().executescript(_data_sql)
yield app
os.close(db_fd)
os.unlink(db_path)
@pytest.fixture
def client(app):
return app.test_client()
@pytest.fixture
def runner(app):
return app.test_client()