Files
courses/bsawf/08-testing-and-code-quality/snakeeyes/tests/conftest.py
T
2025-05-20 11:57:43 -04:00

38 lines
697 B
Python

import pytest
from snakeeyes.app import create_app
@pytest.yield_fixture(scope='session')
def app():
"""
Setup our flask test app, this only gets executed once.
:return: Flask app
"""
params = {
'DEBUG': False,
'TESTING': True,
}
_app = create_app(settings_override=params)
# Establish an application context before running the tests.
ctx = _app.app_context()
ctx.push()
yield _app
ctx.pop()
@pytest.yield_fixture(scope='function')
def client(app):
"""
Setup an app client, this gets executed for each test function.
:param app: Pytest fixture
:return: Flask app client
"""
yield app.test_client()