File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -522,6 +522,29 @@ def test_stacked_responses():
522
522
assert route.call_count == 2
523
523
```
524
524
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
+
525
548
### Shortcuts
526
549
527
550
#### Respond
You can’t perform that action at this time.
0 commit comments