Skip to content

Commit

Permalink
refactor: rename FakeSSLContext to MocketSSLContext
Browse files Browse the repository at this point in the history
  • Loading branch information
betaboon committed Nov 16, 2024
1 parent b38eeda commit cc0a4ff
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ Example:
# Importing the module while Mocket is in control (inside a
# decorated test function or using its context manager would
# be enough for making it work), the alternative is using a
# custom TCPConnector which always return a FakeSSLContext
# custom TCPConnector which always return a MocketSSLContext
# from Mocket like this example is showing.
import aiohttp
import pytest
Expand Down
4 changes: 2 additions & 2 deletions mocket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from mocket.async_mocket import async_mocketize
from mocket.entry import MocketEntry
from mocket.mocketizer import Mocketizer, mocketize
from mocket.ssl import FakeSSLContext
from mocket.ssl import MocketSSLContext
from mocket.state import MocketState


Expand All @@ -25,7 +25,7 @@ def __init__(self) -> None:
"Mocket",
"MocketEntry",
"Mocketizer",
"FakeSSLContext",
"MocketSSLContext",
)

__version__ = "3.13.2"
14 changes: 7 additions & 7 deletions mocket/inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
true_urllib3_wrap_socket,
)
from mocket.ssl import (
FakeSSLContext,
MocketSSLContext,
true_ssl_context,
true_ssl_wrap_socket,
)
Expand Down Expand Up @@ -55,21 +55,21 @@ def enable(namespace=None, truesocket_recording_dir=None):
socket.gethostbyname = socket.__dict__["gethostbyname"] = gethostbyname
socket.getaddrinfo = socket.__dict__["getaddrinfo"] = getaddrinfo
socket.socketpair = socket.__dict__["socketpair"] = socketpair
ssl.wrap_socket = ssl.__dict__["wrap_socket"] = FakeSSLContext.wrap_socket
ssl.SSLContext = ssl.__dict__["SSLContext"] = FakeSSLContext
ssl.wrap_socket = ssl.__dict__["wrap_socket"] = MocketSSLContext.wrap_socket
ssl.SSLContext = ssl.__dict__["SSLContext"] = MocketSSLContext
socket.inet_pton = socket.__dict__["inet_pton"] = inet_pton
urllib3.util.ssl_.wrap_socket = urllib3.util.ssl_.__dict__["wrap_socket"] = (
FakeSSLContext.wrap_socket
MocketSSLContext.wrap_socket
)
urllib3.util.ssl_.ssl_wrap_socket = urllib3.util.ssl_.__dict__[
"ssl_wrap_socket"
] = FakeSSLContext.wrap_socket
] = MocketSSLContext.wrap_socket
urllib3.util.ssl_wrap_socket = urllib3.util.__dict__["ssl_wrap_socket"] = (
FakeSSLContext.wrap_socket
MocketSSLContext.wrap_socket
)
urllib3.connection.ssl_wrap_socket = urllib3.connection.__dict__[
"ssl_wrap_socket"
] = FakeSSLContext.wrap_socket
] = MocketSSLContext.wrap_socket
urllib3.connection.match_hostname = urllib3.connection.__dict__[
"match_hostname"
] = match_hostname
Expand Down
6 changes: 3 additions & 3 deletions mocket/plugins/aiohttp_connector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import contextlib

from mocket import FakeSSLContext
from mocket import MocketSSLContext

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

def _get_ssl_context(self, req: ClientRequest) -> FakeSSLContext:
return FakeSSLContext()
def _get_ssl_context(self, req: ClientRequest) -> MocketSSLContext:
return MocketSSLContext()
2 changes: 1 addition & 1 deletion mocket/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __set__(self, *args):
verify_flags = FakeSetter()


class FakeSSLContext(SuperFakeSSLContext):
class MocketSSLContext(SuperFakeSSLContext):
DUMMY_METHODS = (
"load_default_certs",
"load_verify_locations",
Expand Down

0 comments on commit cc0a4ff

Please sign in to comment.