-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aiohttp
reuses SSLContext instances created at import-time (#259)
* `aiohttp` reuses SSLContext instances created at import-time.
- Loading branch information
1 parent
d0b43a1
commit 8eae0c7
Showing
3 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
from .async_mocket import async_mocketize | ||
from .mocket import Mocket, MocketEntry, Mocketizer, mocketize | ||
from .mocket import FakeSSLContext, Mocket, MocketEntry, Mocketizer, mocketize | ||
|
||
__all__ = ("async_mocketize", "mocketize", "Mocket", "MocketEntry", "Mocketizer") | ||
__all__ = ( | ||
"async_mocketize", | ||
"mocketize", | ||
"Mocket", | ||
"MocketEntry", | ||
"Mocketizer", | ||
"FakeSSLContext", | ||
) | ||
|
||
__version__ = "3.13.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import contextlib | ||
|
||
from mocket import FakeSSLContext | ||
|
||
with contextlib.suppress(ModuleNotFoundError): | ||
from aiohttp import ClientRequest | ||
from aiohttp.connector import TCPConnector | ||
|
||
class MocketTCPConnector(TCPConnector): | ||
""" | ||
`aiohttp` reuses SSLContext instances created at import-time, | ||
making it more difficult for Mocket to do its job. | ||
This is an attempt to make things smoother, at the cost of | ||
slightly patching the `ClientSession` while testing. | ||
""" | ||
|
||
def _get_ssl_context(self, req: ClientRequest) -> FakeSSLContext: | ||
return FakeSSLContext() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters