@@ -1140,23 +1140,30 @@ def _load_verify_directory_locations_capath(self, capath):
1140
1140
1141
1141
self ._load_verify_locations_test (None , capath )
1142
1142
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 ):
1144
1158
"""
1145
1159
`Context.load_verify_locations` accepts a directory name as a `bytes`
1146
1160
instance and uses the certificates within for verification purposes.
1147
1161
"""
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 )
1160
1167
1161
1168
def test_load_verify_locations_wrong_args (self ):
1162
1169
"""
@@ -2838,23 +2845,24 @@ def test_wantWriteError(self):
2838
2845
"""
2839
2846
client_socket , server_socket = socket_pair ()
2840
2847
# 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
2842
2850
# completely fill the buffer. Even though the socket API is allowed to
2843
2851
# signal a short write via its return value it seems this doesn't
2844
2852
# always happen on all platforms (FreeBSD and OS X particular) for the
2845
2853
# 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
+ )
2858
2866
2859
2867
ctx = Context (SSLv23_METHOD )
2860
2868
conn = Connection (ctx , client_socket )
@@ -3753,13 +3761,16 @@ def test_unexpected_EOF(self):
3753
3761
"""
3754
3762
If the connection is lost before an orderly SSL shutdown occurs,
3755
3763
`OpenSSL.SSL.SysCallError` is raised with a message of
3756
- "Unexpected EOF".
3764
+ "Unexpected EOF" (or WSAECONNRESET on Windows) .
3757
3765
"""
3758
3766
server_conn , client_conn = loopback ()
3759
3767
client_conn .sock_shutdown (SHUT_RDWR )
3760
3768
with pytest .raises (SysCallError ) as err :
3761
3769
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" )
3763
3774
3764
3775
def _check_client_ca_list (self , func ):
3765
3776
"""
0 commit comments