mirror of https://github.com/tiangolo/fastapi.git
📝 Update includes in `docs/en/docs/advanced/async-tests.md` (#12568)
This commit is contained in:
parent
4b9e76bde2
commit
dfdecfd9c9
|
|
@ -32,15 +32,11 @@ For a simple example, let's consider a file structure similar to the one describ
|
||||||
|
|
||||||
The file `main.py` would have:
|
The file `main.py` would have:
|
||||||
|
|
||||||
```Python
|
{* ../../docs_src/async_tests/main.py *}
|
||||||
{!../../docs_src/async_tests/main.py!}
|
|
||||||
```
|
|
||||||
|
|
||||||
The file `test_main.py` would have the tests for `main.py`, it could look like this now:
|
The file `test_main.py` would have the tests for `main.py`, it could look like this now:
|
||||||
|
|
||||||
```Python
|
{* ../../docs_src/async_tests/test_main.py *}
|
||||||
{!../../docs_src/async_tests/test_main.py!}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Run it
|
## Run it
|
||||||
|
|
||||||
|
|
@ -60,9 +56,7 @@ $ pytest
|
||||||
|
|
||||||
The marker `@pytest.mark.anyio` tells pytest that this test function should be called asynchronously:
|
The marker `@pytest.mark.anyio` tells pytest that this test function should be called asynchronously:
|
||||||
|
|
||||||
```Python hl_lines="7"
|
{* ../../docs_src/async_tests/test_main.py hl[7] *}
|
||||||
{!../../docs_src/async_tests/test_main.py!}
|
|
||||||
```
|
|
||||||
|
|
||||||
/// tip
|
/// tip
|
||||||
|
|
||||||
|
|
@ -72,9 +66,7 @@ Note that the test function is now `async def` instead of just `def` as before w
|
||||||
|
|
||||||
Then we can create an `AsyncClient` with the app, and send async requests to it, using `await`.
|
Then we can create an `AsyncClient` with the app, and send async requests to it, using `await`.
|
||||||
|
|
||||||
```Python hl_lines="9-12"
|
{* ../../docs_src/async_tests/test_main.py hl[9:12] *}
|
||||||
{!../../docs_src/async_tests/test_main.py!}
|
|
||||||
```
|
|
||||||
|
|
||||||
This is the equivalent to:
|
This is the equivalent to:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue