File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING
4+
5+ import aiohttp
6+ import pytest
7+
8+
9+ if TYPE_CHECKING :
10+ import aioresponses
11+
12+
13+ class TestSessionFixture :
14+ """Grouping for aiohttp.ClientSession fixture tests."""
15+
16+ @pytest .mark .asyncio
17+ async def test_session_fixture_no_requests (self , http_session : aiohttp .ClientSession ):
18+ """
19+ Test all requests fail.
20+
21+ This means that aioresponses is being requested by the http_session fixture.
22+ """
23+ url = "https://github.com/"
24+
25+ with pytest .raises (aiohttp .ClientConnectionError ):
26+ await http_session .get (url )
27+
28+ @pytest .mark .asyncio
29+ async def test_session_fixture_mock_requests (
30+ self , aioresponse : aioresponses .aioresponses , http_session : aiohttp .ClientSession
31+ ):
32+ """
33+ Test all requests fail.
34+
35+ This means that aioresponses is being requested by the http_session fixture.
36+ """
37+ url = "https://github.com/"
38+ status = 200
39+ aioresponse .get (url , status = status )
40+
41+ async with http_session .get (url ) as resp :
42+ assert status == resp .status
You can’t perform that action at this time.
0 commit comments