Skip to content

Commit

Permalink
change fixture scope
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHYang committed Oct 16, 2024
1 parent 302735a commit 955aab3
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from contextlib import ExitStack
from dataclasses import asdict
from itertools import count, starmap
from secrets import token_hex
from typing import Generator, Iterator, List, Optional, Tuple, cast
from unittest import mock

Expand All @@ -11,7 +11,6 @@
from faker import Faker
from opentelemetry.sdk.trace import ReadableSpan
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter
from phoenix.auth import REQUIREMENTS_FOR_PHOENIX_SECRET
from phoenix.config import (
ENV_PHOENIX_GRPC_PORT,
ENV_PHOENIX_PORT,
Expand Down Expand Up @@ -131,22 +130,22 @@ def _env_postgresql_schema(
yield


@pytest.fixture(scope="module")
def _emails(_fake: Faker) -> Iterator[_Email]:
return (_fake.unique.email() for _ in count())
@pytest.fixture
def _emails() -> Iterator[_Email]:
return (f"{token_hex(32)}@{token_hex(32)}.com" for _ in count())


@pytest.fixture(scope="module")
def _passwords(_fake: Faker) -> Iterator[_Password]:
return (_fake.unique.password(**asdict(REQUIREMENTS_FOR_PHOENIX_SECRET)) for _ in count())
@pytest.fixture
def _passwords() -> Iterator[_Password]:
return (token_hex(32) for _ in count())


@pytest.fixture(scope="module")
def _usernames(_fake: Faker) -> Iterator[_Username]:
return (_fake.unique.pystr() for _ in count())
@pytest.fixture
def _usernames() -> Iterator[_Username]:
return (token_hex(32) for _ in count())


@pytest.fixture(scope="module")
@pytest.fixture
def _profiles(
_emails: Iterator[_Email],
_passwords: Iterator[_Password],
Expand All @@ -155,7 +154,7 @@ def _profiles(
return starmap(_Profile, zip(_emails, _passwords, _usernames))


@pytest.fixture(scope="module")
@pytest.fixture
def _users(
_profiles: Iterator[_Profile],
) -> _UserGenerator:
Expand All @@ -170,7 +169,7 @@ def _() -> Generator[Optional[_User], Tuple[UserRoleInput, Optional[_Profile]],
return cast(_UserGenerator, g)


@pytest.fixture(scope="module")
@pytest.fixture
def _new_user(
_users: _UserGenerator,
) -> _UserFactory:
Expand All @@ -185,7 +184,7 @@ def _(
return _


@pytest.fixture(scope="module")
@pytest.fixture
def _get_user(
_new_user: _UserFactory,
) -> _GetUser:
Expand Down

0 comments on commit 955aab3

Please sign in to comment.