Skip to content

Commit

Permalink
Deploying to gh-pages from @ litestar-org/litestar@da30d9f 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin committed Jan 5, 2025
1 parent 9c34b74 commit 47999d4
Show file tree
Hide file tree
Showing 10 changed files with 270 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 3922/_sources/reference/testing.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ testing


.. automodule:: litestar.testing
:members: RequestFactory, BaseTestClient, TestClient, AsyncTestClient, create_async_test_client, create_test_client
:members: RequestFactory, BaseTestClient, TestClient, AsyncTestClient, create_async_test_client, create_test_client, subprocess_sync_client, subprocess_async_client
:undoc-members: WebSocketTestSession


Expand Down
25 changes: 25 additions & 0 deletions 3922/_sources/usage/testing.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,31 @@ But also this:
assert response.text == "healthy"
Running a live server
---------------------

The test clients make use of HTTPX's ability to directly call into an ASGI app, without
having to run an actual server. In most cases this is sufficient but there are some
exceptions where this won't work, due to the limitations of the emulated client-server
communication.

For example, when using server-sent events with an infinite generator, it will lock up
the test client, since HTTPX tries to consume the full response before returning a
request.

Litestar offers two helper functions,
:func:`litestar.testing.subprocess_sync_client` and
:func:`litestar.testing.subprocess_async_client` that will
launch a Litestar instance with in a subprocess and set up an httpx client for running
tests. You can either load your actual app file or create subsets from it as you would
with the regular test client setup:

.. literalinclude:: /examples/testing/subprocess_sse_app.py
:language: python

.. literalinclude:: /examples/testing/test_subprocess_sse.py
:language: python

RequestFactory
--------------

Expand Down
22 changes: 18 additions & 4 deletions 3922/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -2938,6 +2938,10 @@ <h2 id="A">A</h2>
<li><a href="reference/testing.html#litestar.testing.RequestFactory.app">(litestar.testing.RequestFactory attribute)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.RequestFactory.params.app">(litestar.testing.RequestFactory parameter)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.subprocess_async_client.params.app">(litestar.testing.subprocess_async_client parameter)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.subprocess_sync_client.params.app">(litestar.testing.subprocess_sync_client parameter)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.TestClient.app">(litestar.testing.TestClient attribute)</a>
</li>
Expand Down Expand Up @@ -10833,10 +10837,10 @@ <h2 id="S">S</h2>
<li><a href="reference/stores/valkey.html#litestar.stores.valkey.ValkeyStore.set">(litestar.stores.valkey.ValkeyStore method)</a>
</li>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/concurrency.html#litestar.concurrency.set_asyncio_executor">set_asyncio_executor() (in module litestar.concurrency)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/middleware/rate_limit.html#litestar.middleware.rate_limit.RateLimitMiddleware.set_cached_history">set_cached_history() (litestar.middleware.rate_limit.RateLimitMiddleware method)</a>
</li>
<li><a href="reference/response/base.html#litestar.response.base.Response.set_cookie">set_cookie() (litestar.response.base.Response method)</a>
Expand Down Expand Up @@ -11280,6 +11284,10 @@ <h2 id="S">S</h2>
</li>
</ul></li>
<li><a href="reference/security/jwt.html#litestar.security.jwt.Token.sub">sub (litestar.security.jwt.Token attribute)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.subprocess_async_client">subprocess_async_client() (in module litestar.testing)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.subprocess_sync_client">subprocess_sync_client() (in module litestar.testing)</a>
</li>
<li><a href="reference/connection.html#litestar.connection.WebSocket.accept.params.subprotocols">subprotocols (litestar.connection.WebSocket.accept parameter)</a>

Expand Down Expand Up @@ -12249,10 +12257,10 @@ <h2 id="W">W</h2>
</li>
<li><a href="reference/routes.html#litestar.routes.WebSocketRoute">WebSocketRoute (class in litestar.routes)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/handlers.html#litestar.handlers.WebsocketRouteHandler">WebsocketRouteHandler (class in litestar.handlers)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="reference/types.html#litestar.types.WebSocketScope">WebSocketScope (class in litestar.types)</a>
</li>
<li><a href="reference/types.html#litestar.types.WebSocketSendEvent">WebSocketSendEvent (class in litestar.types)</a>
Expand All @@ -12279,6 +12287,12 @@ <h2 id="W">W</h2>
</ul></li>
<li><a href="reference/datastructures/index.html#litestar.datastructures.URL.with_replacements">with_replacements() (litestar.datastructures.URL method)</a>
</li>
<li><a href="reference/testing.html#litestar.testing.subprocess_async_client.params.workdir">workdir (litestar.testing.subprocess_async_client parameter)</a>

<ul>
<li><a href="reference/testing.html#litestar.testing.subprocess_sync_client.params.workdir">(litestar.testing.subprocess_sync_client parameter)</a>
</li>
</ul></li>
<li><a href="reference/events.html#litestar.events.EventListener.wrap_in_error_handler">wrap_in_error_handler() (litestar.events.EventListener static method)</a>
</li>
<li><a href="reference/openapi/spec.html#litestar.openapi.spec.XML.wrapped">wrapped (litestar.openapi.spec.XML attribute)</a>
Expand Down
Binary file modified 3922/objects.inv
Binary file not shown.
4 changes: 2 additions & 2 deletions 3922/reference/app.html

Large diffs are not rendered by default.

Loading

0 comments on commit 47999d4

Please sign in to comment.