7
7
import respx
8
8
from respx import ASGIHandler , WSGIHandler
9
9
from respx .mocks import Mocker
10
+ from respx .models import AllCalledAssertionError , AllMockedAssertionError
10
11
from respx .router import MockRouter
11
12
12
- # from respx.transports import MockTransport
13
-
14
13
15
14
@pytest .mark .asyncio
16
15
@respx .mock
@@ -112,7 +111,7 @@ def test(respx_mock):
112
111
assert respx .calls .call_count == 0
113
112
assert respx_mock .calls .call_count == 1
114
113
115
- with pytest .raises (AssertionError , match = "not mocked" ):
114
+ with pytest .raises (AllMockedAssertionError ):
116
115
httpx .post ("https://foo.bar/" )
117
116
118
117
assert respx .calls .call_count == 0
@@ -139,7 +138,7 @@ async def test(respx_mock):
139
138
assert respx .calls .call_count == 0
140
139
assert respx_mock .calls .call_count == 1
141
140
142
- with pytest .raises (AssertionError , match = "not mocked" ):
141
+ with pytest .raises (AllMockedAssertionError ):
143
142
httpx .post ("https://foo.bar/" )
144
143
145
144
assert respx .calls .call_count == 0
@@ -415,7 +414,7 @@ async def test_start_stop(client):
415
414
@pytest .mark .parametrize (
416
415
"assert_all_called,do_post,raises" ,
417
416
[
418
- (True , False , pytest .raises (AssertionError )),
417
+ (True , False , pytest .raises (AllCalledAssertionError )),
419
418
(True , True , does_not_raise ()),
420
419
(False , True , does_not_raise ()),
421
420
(False , False , does_not_raise ()),
@@ -438,7 +437,7 @@ async def test_assert_all_called(client, assert_all_called, do_post, raises):
438
437
@pytest .mark .asyncio
439
438
@pytest .mark .parametrize (
440
439
"assert_all_mocked,raises" ,
441
- [(True , pytest .raises (AssertionError )), (False , does_not_raise ())],
440
+ [(True , pytest .raises (AllMockedAssertionError )), (False , does_not_raise ())],
442
441
)
443
442
async def test_assert_all_mocked (client , assert_all_mocked , raises ):
444
443
with raises :
@@ -574,7 +573,7 @@ def test(respx_mock):
574
573
client .get ("https://pass-through/" )
575
574
assert pass_route .call_count == 1
576
575
577
- with pytest .raises (AssertionError , match = "not mocked" ):
576
+ with pytest .raises (AllMockedAssertionError ):
578
577
client .get ("https://not-mocked/" )
579
578
580
579
with respx .mock (using = "httpx" ): # extra registered router
@@ -615,7 +614,7 @@ async def content():
615
614
await client .get ("https://pass-through/" )
616
615
assert pass_route .call_count == 1
617
616
618
- with pytest .raises (AssertionError , match = "not mocked" ):
617
+ with pytest .raises (AllMockedAssertionError ):
619
618
await client .get ("https://not-mocked/" )
620
619
621
620
async with respx .mock (using = "httpx" ): # extra registered router
0 commit comments