Skip to content

Commit 32eeefb

Browse files
committed
refactor: rename FakeSSLContext to MocketSSLContext
1 parent 83986fb commit 32eeefb

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

mocket/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
from mocket.entry import MocketEntry
33
from mocket.mocket import Mocket
44
from mocket.mocketizer import Mocketizer, mocketize
5-
from mocket.ssl.context import FakeSSLContext
5+
from mocket.ssl.context import MocketSSLContext
6+
7+
# NOTE this is here for backwards-compat to keep old import-paths working
8+
from mocket.ssl.context import MocketSSLContext as FakeSSLContext
69

710
__all__ = (
811
"async_mocketize",
912
"mocketize",
1013
"Mocket",
1114
"MocketEntry",
1215
"Mocketizer",
16+
"MocketSSLContext",
1317
"FakeSSLContext",
1418
)
1519

mocket/inject.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def enable(
2929
mock_socketpair,
3030
mock_urllib3_match_hostname,
3131
)
32-
from mocket.ssl.context import FakeSSLContext
32+
from mocket.ssl.context import MocketSSLContext
3333

3434
Mocket._namespace = namespace
3535
Mocket._truesocket_recording_dir = truesocket_recording_dir
@@ -48,21 +48,21 @@ def enable(
4848
socket.gethostbyname = socket.__dict__["gethostbyname"] = mock_gethostbyname
4949
socket.getaddrinfo = socket.__dict__["getaddrinfo"] = mock_getaddrinfo
5050
socket.socketpair = socket.__dict__["socketpair"] = mock_socketpair
51-
ssl.wrap_socket = ssl.__dict__["wrap_socket"] = FakeSSLContext.wrap_socket
52-
ssl.SSLContext = ssl.__dict__["SSLContext"] = FakeSSLContext
51+
ssl.wrap_socket = ssl.__dict__["wrap_socket"] = MocketSSLContext.wrap_socket
52+
ssl.SSLContext = ssl.__dict__["SSLContext"] = MocketSSLContext
5353
socket.inet_pton = socket.__dict__["inet_pton"] = mock_inet_pton
5454
urllib3.util.ssl_.wrap_socket = urllib3.util.ssl_.__dict__["wrap_socket"] = (
55-
FakeSSLContext.wrap_socket
55+
MocketSSLContext.wrap_socket
5656
)
5757
urllib3.util.ssl_.ssl_wrap_socket = urllib3.util.ssl_.__dict__[
5858
"ssl_wrap_socket"
59-
] = FakeSSLContext.wrap_socket
59+
] = MocketSSLContext.wrap_socket
6060
urllib3.util.ssl_wrap_socket = urllib3.util.__dict__["ssl_wrap_socket"] = (
61-
FakeSSLContext.wrap_socket
61+
MocketSSLContext.wrap_socket
6262
)
6363
urllib3.connection.ssl_wrap_socket = urllib3.connection.__dict__[
6464
"ssl_wrap_socket"
65-
] = FakeSSLContext.wrap_socket
65+
] = MocketSSLContext.wrap_socket
6666
urllib3.connection.match_hostname = urllib3.connection.__dict__[
6767
"match_hostname"
6868
] = mock_urllib3_match_hostname

mocket/plugins/aiohttp_connector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import contextlib
22

3-
from mocket import FakeSSLContext
3+
from mocket import MocketSSLContext
44

55
with contextlib.suppress(ModuleNotFoundError):
66
from aiohttp import ClientRequest
@@ -14,5 +14,5 @@ class MocketTCPConnector(TCPConnector):
1414
slightly patching the `ClientSession` while testing.
1515
"""
1616

17-
def _get_ssl_context(self, req: ClientRequest) -> FakeSSLContext:
18-
return FakeSSLContext()
17+
def _get_ssl_context(self, req: ClientRequest) -> MocketSSLContext:
18+
return MocketSSLContext()

mocket/ssl/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
true_urllib3_wrap_socket = urllib3_wrap_socket
2828

2929

30-
class SuperFakeSSLContext:
30+
class _MocketSSLContext:
3131
"""For Python 3.6 and newer."""
3232

3333
class FakeSetter(int):
@@ -40,7 +40,7 @@ def __set__(self, *args: Any) -> None:
4040
verify_flags = FakeSetter()
4141

4242

43-
class FakeSSLContext(SuperFakeSSLContext):
43+
class MocketSSLContext(_MocketSSLContext):
4444
DUMMY_METHODS = (
4545
"load_default_certs",
4646
"load_verify_locations",

0 commit comments

Comments
 (0)