conftest.py 750 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. '''
  2. this file is part of "El Botadero"
  3. copyright 2018 Rodrigo Garcia <strysg@riseup.net>
  4. AGPL liberated.
  5. '''
  6. import os
  7. import tempfile
  8. import random
  9. import pytest
  10. from botadero import create_app
  11. from botadero.shared import globalParams
  12. from botadero.database import get_db
  13. @pytest.fixture(scope='session')
  14. def app():
  15. db_fd, db_path = tempfile.mkstemp(suffix='.db')
  16. # create_app() tambien contiene inicializadores para la base de datos
  17. app = create_app(db_path=db_path, testing=True)
  18. yield app
  19. os.close(db_fd)
  20. os.unlink(db_path)
  21. @pytest.fixture
  22. def client(app):
  23. return app.test_client()
  24. @pytest.fixture
  25. def runner(app):
  26. return app.test_cli_runner()
  27. @pytest.fixture
  28. def db(app):
  29. yield get_db()