Skip to content

Commit 3c35da1

Browse files
authored
Enhance docs on iterable side effects (#255)
1 parent e97b677 commit 3c35da1

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/guide.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,29 @@ def test_stacked_responses():
522522
assert route.call_count == 2
523523
```
524524

525+
Once the iterable is *exhausted*, the route will fallback and respond with the `return_value`, if set.
526+
527+
``` python
528+
import httpx
529+
import respx
530+
531+
532+
@respx.mock
533+
def test_stacked_responses():
534+
respx.post("https://example.org/").mock(
535+
side_effect=[httpx.Response(201)],
536+
return_value=httpx.Response(200)
537+
)
538+
539+
response1 = httpx.post("https://example.org/")
540+
response2 = httpx.post("https://example.org/")
541+
response3 = httpx.post("https://example.org/")
542+
543+
assert response1.status_code == 201
544+
assert response2.status_code == 200
545+
assert response3.status_code == 200
546+
```
547+
525548
### Shortcuts
526549

527550
#### Respond

0 commit comments

Comments
 (0)