TP_JO2024/athlete/conftest.py
2024-03-27 15:20:10 +01:00

27 lines
720 B
Python

import pytest
import shutil
from pathlib import Path
from app import create_app
from flask import request
@pytest.fixture()
def app():
app = create_app()
# Copy the sample to the test folder using python
shutil.copy(Path(__file__).parent.parent / 'sample' / 'athletes.json', Path(__file__).parent / 'tests' / 'athletes.json')
app.config.update({
"TESTING": True,
"ATHLETE_FILE": Path(__file__).parent / 'tests' / 'athletes.json'
})
yield app
# Remove the file after the test
(Path(__file__).parent / 'tests' / 'athletes.json').unlink()
@pytest.fixture()
def client(app):
return app.test_client()
@pytest.fixture()
def runner(app):
return app.test_cli_runner()