Files
notytex/tests/conftest.py
2025-08-04 08:43:42 +02:00

35 lines
621 B
Python

import pytest
import tempfile
import os
from app import create_app
from models import db
@pytest.fixture
def app():
db_fd, db_path = tempfile.mkstemp()
app = create_app('testing')
app.config.update({
'TESTING': True,
'SQLALCHEMY_DATABASE_URI': f'sqlite:///{db_path}',
'WTF_CSRF_ENABLED': False,
})
with app.app_context():
db.create_all()
yield app
db.drop_all()
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_cli_runner()