TP_JO2024/medaille/conftest.py

26 lines
699 B
Python
Raw Normal View History

2024-03-27 14:17:05 +01:00
import pytest
import shutil
from pathlib import Path
from app import create_app
@pytest.fixture()
def app():
app = create_app()
# Copy the sample to the test folder using python
shutil.copy(Path(__file__).parent.parent / 'sample' / 'medailles.json', Path(__file__).parent / 'tests' / 'medailles.json')
app.config.update({
"TESTING": True,
"MEDAILLE_FILE": Path(__file__).parent / 'tests' / 'medailles.json'
})
yield app
# Remove the file after the test
(Path(__file__).parent / 'tests' / 'medailles.json').unlink()
@pytest.fixture()
def client(app):
return app.test_client()
@pytest.fixture()
def runner(app):
return app.test_cli_runner()