File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,9 @@ def _inject_stdlib_ssl() -> None:
6969 _replace (ssl , "SSLContext" , MocketSSLContext )
7070
7171 if python_version () < Version ("3.12.0" ):
72- _replace (ssl , "wrap_socket" , MocketSSLContext .wrap_socket )
72+ from mocket .ssl .context import mock_wrap_socket
73+
74+ _replace (ssl , "wrap_socket" , mock_wrap_socket )
7375
7476
7577def _restore_stdlib_ssl () -> None :
Original file line number Diff line number Diff line change @@ -58,12 +58,16 @@ def dummy_method(*args: Any, **kwargs: Any) -> Any:
5858 for m in self .DUMMY_METHODS :
5959 setattr (self , m , dummy_method )
6060
61- @staticmethod
62- def wrap_socket (sock : MocketSocket , * args : Any , ** kwargs : Any ) -> MocketSSLSocket :
61+ def wrap_socket (
62+ self ,
63+ sock : MocketSocket ,
64+ * args : Any ,
65+ ** kwargs : Any ,
66+ ) -> MocketSSLSocket :
6367 return MocketSSLSocket ._create (sock , * args , ** kwargs )
6468
65- @staticmethod
6669 def wrap_bio (
70+ self ,
6771 incoming : Any , # _ssl.MemoryBIO
6872 outgoing : Any , # _ssl.MemoryBIO
6973 server_side : bool = False ,
@@ -72,3 +76,12 @@ def wrap_bio(
7276 ssl_obj = MocketSSLSocket ()
7377 ssl_obj ._host = server_hostname
7478 return ssl_obj
79+
80+
81+ def mock_wrap_socket (
82+ sock : MocketSocket ,
83+ * args : Any ,
84+ ** kwargs : Any ,
85+ ) -> MocketSSLSocket :
86+ context = MocketSSLContext ()
87+ return context .wrap_socket (sock , * args , ** kwargs )
You can’t perform that action at this time.
0 commit comments