Skip to content

Commit

Permalink
fixed fixture scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
hasnain095 committed Apr 4, 2023
1 parent 59362cc commit 76e806e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions users/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
from app.models.users import User


@pytest.fixture()
@pytest.fixture(scope="session")
async def connection():
async with engine.begin() as conn:
yield conn
await conn.rollback()


@pytest.fixture()
@pytest.fixture(scope="session")
async def session(connection: AsyncConnection):
async with AsyncSession(connection, expire_on_commit=False) as _session:
yield _session
Expand All @@ -41,7 +41,7 @@ def event_loop():
loop.close()


@pytest.fixture()
@pytest.fixture(scope="session")
async def client():
async with AsyncClient(app=app, base_url="http://test") as ac, LifespanManager(app):
yield ac
Expand All @@ -58,7 +58,7 @@ async def superuser_token_headers(client: AsyncClient) -> Dict[str, str]:
return {"Authorization": f"Bearer {access_token}"}


@pytest.fixture()
@pytest.fixture(scope="session")
async def create_non_superuser(session: AsyncSession) -> Dict[str, str]:
email = "test_user@test.com"
password = "Ksd8nASD1_Hjns!P"
Expand All @@ -71,7 +71,7 @@ async def create_non_superuser(session: AsyncSession) -> Dict[str, str]:
return {"email": email, "password": password}


@pytest.fixture()
@pytest.fixture(scope="session")
async def user_token_headers(client: AsyncClient, create_non_superuser: Dict[str, str]) -> Dict[str, str]:
login_data = {
"username": create_non_superuser["email"],
Expand Down

0 comments on commit 76e806e

Please sign in to comment.