@@ -1140,23 +1140,30 @@ def _load_verify_directory_locations_capath(self, capath):
11401140
11411141 self ._load_verify_locations_test (None , capath )
11421142
1143- def test_load_verify_directory_bytes_capath (self , tmpfile ):
1143+ @pytest .mark .parametrize (
1144+ "pathtype" ,
1145+ [
1146+ "ascii_path" ,
1147+ pytest .param (
1148+ "unicode_path" ,
1149+ marks = pytest .mark .skipif (
1150+ platform == "win32" ,
1151+ reason = "Unicode paths not supported on Windows" ,
1152+ ),
1153+ ),
1154+ ],
1155+ )
1156+ @pytest .mark .parametrize ("argtype" , ["bytes_arg" , "unicode_arg" ])
1157+ def test_load_verify_directory_capath (self , pathtype , argtype , tmpfile ):
11441158 """
11451159 `Context.load_verify_locations` accepts a directory name as a `bytes`
11461160 instance and uses the certificates within for verification purposes.
11471161 """
1148- self ._load_verify_directory_locations_capath (
1149- tmpfile + NON_ASCII .encode (getfilesystemencoding ())
1150- )
1151-
1152- def test_load_verify_directory_unicode_capath (self , tmpfile ):
1153- """
1154- `Context.load_verify_locations` accepts a directory name as a `unicode`
1155- instance and uses the certificates within for verification purposes.
1156- """
1157- self ._load_verify_directory_locations_capath (
1158- tmpfile .decode (getfilesystemencoding ()) + NON_ASCII
1159- )
1162+ if pathtype == "unicode_path" :
1163+ tmpfile += NON_ASCII .encode (getfilesystemencoding ())
1164+ if argtype == "unicode_arg" :
1165+ tmpfile = tmpfile .decode (getfilesystemencoding ())
1166+ self ._load_verify_directory_locations_capath (tmpfile )
11601167
11611168 def test_load_verify_locations_wrong_args (self ):
11621169 """
@@ -2838,23 +2845,24 @@ def test_wantWriteError(self):
28382845 """
28392846 client_socket , server_socket = socket_pair ()
28402847 # Fill up the client's send buffer so Connection won't be able to write
2841- # anything. Only write a single byte at a time so we can be sure we
2848+ # anything. Start by sending larger chunks (Windows Socket I/O is slow)
2849+ # and continue by writing a single byte at a time so we can be sure we
28422850 # completely fill the buffer. Even though the socket API is allowed to
28432851 # signal a short write via its return value it seems this doesn't
28442852 # always happen on all platforms (FreeBSD and OS X particular) for the
28452853 # very last bit of available buffer space.
2846- msg = b"x"
2847- for i in range (1024 * 1024 * 64 ):
2848- try :
2849- client_socket .send (msg )
2850- except error as e :
2851- if e .errno == EWOULDBLOCK :
2852- break
2853- raise
2854- else :
2855- pytest .fail (
2856- "Failed to fill socket buffer, cannot test BIO want write"
2857- )
2854+ for msg in [ b"x" * 65536 , b"x" ]:
2855+ for i in range (1024 * 1024 * 64 ):
2856+ try :
2857+ client_socket .send (msg )
2858+ except error as e :
2859+ if e .errno == EWOULDBLOCK :
2860+ break
2861+ raise # pragma: no cover
2862+ else : # pragma: no cover
2863+ pytest .fail (
2864+ "Failed to fill socket buffer, cannot test BIO want write"
2865+ )
28582866
28592867 ctx = Context (SSLv23_METHOD )
28602868 conn = Connection (ctx , client_socket )
@@ -3753,13 +3761,16 @@ def test_unexpected_EOF(self):
37533761 """
37543762 If the connection is lost before an orderly SSL shutdown occurs,
37553763 `OpenSSL.SSL.SysCallError` is raised with a message of
3756- "Unexpected EOF".
3764+ "Unexpected EOF" (or WSAECONNRESET on Windows) .
37573765 """
37583766 server_conn , client_conn = loopback ()
37593767 client_conn .sock_shutdown (SHUT_RDWR )
37603768 with pytest .raises (SysCallError ) as err :
37613769 server_conn .recv (1024 )
3762- assert err .value .args == (- 1 , "Unexpected EOF" )
3770+ if platform == "win32" :
3771+ assert err .value .args == (10054 , "WSAECONNRESET" )
3772+ else :
3773+ assert err .value .args == (- 1 , "Unexpected EOF" )
37633774
37643775 def _check_client_ca_list (self , func ):
37653776 """
0 commit comments