File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ def enable(
3636 mock_inet_pton ,
3737 mock_socketpair ,
3838 )
39- from mocket .ssl .context import MocketSSLContext
39+ from mocket .ssl .context import MocketSSLContext , mock_wrap_socket
4040 from mocket .urllib3 import (
4141 mock_match_hostname as mock_urllib3_match_hostname ,
4242 )
@@ -56,7 +56,7 @@ def enable(
5656 (socket , "socketpair" ): mock_socketpair ,
5757 # stdlib: ssl
5858 (ssl , "SSLContext" ): MocketSSLContext ,
59- (ssl , "wrap_socket" ): MocketSSLContext . wrap_socket , # python < 3.12.0
59+ (ssl , "wrap_socket" ): mock_wrap_socket , # python < 3.12.0
6060 # urllib3
6161 (urllib3 .connection , "match_hostname" ): mock_urllib3_match_hostname ,
6262 (urllib3 .connection , "ssl_wrap_socket" ): mock_urllib3_ssl_wrap_socket ,
Original file line number Diff line number Diff line change @@ -49,12 +49,16 @@ def dummy_method(*args: Any, **kwargs: Any) -> Any:
4949 for m in self .DUMMY_METHODS :
5050 setattr (self , m , dummy_method )
5151
52- @staticmethod
53- def wrap_socket (sock : MocketSocket , * args : Any , ** kwargs : Any ) -> MocketSSLSocket :
52+ def wrap_socket (
53+ self ,
54+ sock : MocketSocket ,
55+ * args : Any ,
56+ ** kwargs : Any ,
57+ ) -> MocketSSLSocket :
5458 return MocketSSLSocket ._create (sock , * args , ** kwargs )
5559
56- @staticmethod
5760 def wrap_bio (
61+ self ,
5862 incoming : Any , # _ssl.MemoryBIO
5963 outgoing : Any , # _ssl.MemoryBIO
6064 server_side : bool = False ,
@@ -63,3 +67,12 @@ def wrap_bio(
6367 ssl_obj = MocketSSLSocket ()
6468 ssl_obj ._host = server_hostname
6569 return ssl_obj
70+
71+
72+ def mock_wrap_socket (
73+ sock : MocketSocket ,
74+ * args : Any ,
75+ ** kwargs : Any ,
76+ ) -> MocketSSLSocket :
77+ context = MocketSSLContext ()
78+ return context .wrap_socket (sock , * args , ** kwargs )
You can’t perform that action at this time.
0 commit comments