conftest.py 547 B

123456789101112131415161718192021222324
  1. import os
  2. import pytest
  3. from flask import Flask
  4. # Getting the absolute path of the current file's directory
  5. ABS_PATH = os.path.dirname(os.path.abspath(__file__))
  6. # Getting the absolute path of the project's root directory
  7. PROJECT_DIR = os.path.abspath(os.path.join(ABS_PATH, os.pardir, os.pardir))
  8. CACHED_APP = Flask(__name__)
  9. CACHED_APP.config.update({"TESTING": True})
  10. @pytest.fixture
  11. def app() -> Flask:
  12. return CACHED_APP
  13. @pytest.fixture(autouse=True)
  14. def _provide_app_context(app: Flask):
  15. with app.app_context():
  16. yield