conftest.py 989 B

1234567891011121314151617181920212223242526272829303132333435
  1. # (c) Nelen & Schuurmans
  2. import asyncio
  3. import os
  4. import pytest
  5. from clean_python.testing import setup_debugger
  6. def pytest_sessionstart(session):
  7. """
  8. Called after the Session object has been created and
  9. before performing collection and entering the run test loop.
  10. """
  11. setup_debugger()
  12. @pytest.fixture(scope="session")
  13. def event_loop(request):
  14. """Create an instance of the default event loop per test session.
  15. Async fixtures need the event loop, and so must have the same or narrower scope than
  16. the event_loop fixture. Since we have async session-scoped fixtures, the default
  17. event_loop fixture, which has function scope, cannot be used. See:
  18. https://github.com/pytest-dev/pytest-asyncio#async-fixtures
  19. """
  20. loop = asyncio.get_event_loop_policy().new_event_loop()
  21. yield loop
  22. loop.close()
  23. @pytest.fixture(scope="session")
  24. async def postgres_url():
  25. return os.environ.get("POSTGRES_URL", "postgres:postgres@localhost:5432")