Skip to content

Commit

Permalink
fix: configure default loop scope (#3939)
Browse files Browse the repository at this point in the history
* fix: configure default loop scope

* fix: remove scoping on subprocess client

* fix: temp ignore

* fix: modify loop scope

* fix: make test async
  • Loading branch information
cofin authored Jan 10, 2025
1 parent 4c7166a commit 518af0d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
(PY_CLASS, "advanced_alchemy.types.BigIntIdentity"),
(PY_CLASS, "advanced_alchemy.types.JsonB"),
(PY_CLASS, "advanced_alchemy.repository.SQLAlchemyAsyncRepository"),
# docs in flux as we prepare for `advanced_alchemy` 1.0 release. re-enable when finished
(PY_CLASS, "advanced_alchemy.base.UUIDBase"),
(PY_CLASS, "advanced_alchemy.base.UUIDAuditBase"),
(PY_CLASS, "advanced_alchemy.base.BigIntBase"),
(PY_CLASS, "advanced_alchemy.base.BigIntAuditBase"),
]

nitpick_ignore_regex = [
Expand Down
9 changes: 1 addition & 8 deletions docs/examples/testing/test_subprocess_sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

pytestmark = pytest.mark.anyio


@pytest.fixture(scope="session")
def anyio_backend() -> str:
return "asyncio"


ROOT = pathlib.Path(__file__).parent


@pytest.fixture(name="async_client", scope="session")
@pytest.fixture(name="async_client")
async def fx_async_client() -> AsyncIterator[httpx.AsyncClient]:
async with subprocess_async_client(workdir=ROOT, app="subprocess_sse_app:app") as client:
yield client
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ fail_under = 50
[tool.pytest.ini_options]
addopts = "--strict-markers --strict-config --dist=loadgroup -m 'not server_integration'"
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
filterwarnings = [
"error",
# https://github.com/pytest-dev/pytest-asyncio/issues/724
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test_channels/test_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
from litestar.channels import Subscriber
from litestar.channels.subscriber import BacklogStrategy
from litestar.utils.compat import async_next
from tests.unit.test_channels.util import get_from_stream

from .util import get_from_stream


def test_subscriber_backlog_backoff() -> None:
async def test_subscriber_backlog_backoff() -> None:
subscriber = Subscriber(plugin=MagicMock(), max_backlog=2, backlog_strategy="backoff")

assert subscriber.put_nowait(b"foo")
Expand All @@ -23,7 +22,7 @@ def test_subscriber_backlog_backoff() -> None:
assert [subscriber._queue.get_nowait(), subscriber._queue.get_nowait()] == [b"foo", b"bar"]


def test_subscriber_backlog_dropleft() -> None:
async def test_subscriber_backlog_dropleft() -> None:
subscriber = Subscriber(plugin=MagicMock(), max_backlog=2, backlog_strategy="dropleft")

assert subscriber.put_nowait(b"foo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())


ROOT = pathlib.Path(__file__).parent


@pytest.fixture(name="async_client", scope="session")
@pytest.fixture(name="async_client")
async def fx_async_client() -> AsyncIterator[httpx.AsyncClient]:
async with subprocess_async_client(workdir=ROOT, app="demo:app") as client:
yield client


@pytest.fixture(name="sync_client", scope="session")
@pytest.fixture(name="sync_client")
def fx_sync_client() -> Iterator[httpx.Client]:
with subprocess_sync_client(workdir=ROOT, app="demo:app") as client:
yield client
Expand Down

0 comments on commit 518af0d

Please sign in to comment.