Skip to content

Commit 01b717d

Browse files
entomindflayer
authored andcommitted
Test making mocked HTTPS request after a real request
This fails like so: > async def read(self) -> _T: > if not self._buffer and not self._eof: > assert not self._waiter > self._waiter = self._loop.create_future() > try: > > await self._waiter > E aiohttp.client_exceptions.ClientOSError: [Errno 1] [SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2580) > > .devenv/state/venv/lib/python3.11/site-packages/aiohttp/streams.py:622: ClientOSError
1 parent 0307301 commit 01b717d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/tests38/test_http_aiohttp.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import json
22
from unittest import IsolatedAsyncioTestCase
33

4+
import pytest
5+
46
from mocket.async_mocket import async_mocketize
5-
from mocket.mocket import Mocket
7+
from mocket.mocket import Mocket, Mocketizer
68
from mocket.mockhttp import Entry
79
from mocket.plugins.httpretty import HTTPretty, async_httprettified
810

@@ -101,3 +103,16 @@ async def test_httprettish_session(self):
101103
async with session.get(self.target_url) as get_response:
102104
assert get_response.status == 200
103105
assert await get_response.text() == '{"origin": "127.0.0.1"}'
106+
107+
@pytest.mark.skipif('os.getenv("SKIP_TRUE_HTTP", False)')
108+
async def test_mocked_https_request_after_unmocked_https_request(self):
109+
async with aiohttp.ClientSession(timeout=self.timeout) as session:
110+
response = await session.get(self.target_url + "real", ssl=False)
111+
assert response.status == 200
112+
113+
async with Mocketizer(None):
114+
Entry.single_register(Entry.GET, self.target_url + "mocked", status=404)
115+
async with aiohttp.ClientSession(timeout=self.timeout) as session:
116+
response = await session.get(self.target_url + "mocked", ssl=False)
117+
assert response.status == 404
118+
self.assertEqual(len(Mocket.request_list()), 1)

0 commit comments

Comments
 (0)