-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tests on Windows, add Windows CI #1186
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1140,23 +1140,30 @@ def _load_verify_directory_locations_capath(self, capath): | |
|
||
self._load_verify_locations_test(None, capath) | ||
|
||
def test_load_verify_directory_bytes_capath(self, tmpfile): | ||
@pytest.mark.parametrize( | ||
"pathtype", | ||
[ | ||
"ascii_path", | ||
pytest.param( | ||
"unicode_path", | ||
marks=pytest.mark.skipif( | ||
platform == "win32", | ||
reason="Unicode paths not supported on Windows", | ||
), | ||
), | ||
], | ||
) | ||
@pytest.mark.parametrize("argtype", ["bytes_arg", "unicode_arg"]) | ||
def test_load_verify_directory_capath(self, pathtype, argtype, tmpfile): | ||
""" | ||
`Context.load_verify_locations` accepts a directory name as a `bytes` | ||
instance and uses the certificates within for verification purposes. | ||
""" | ||
self._load_verify_directory_locations_capath( | ||
tmpfile + NON_ASCII.encode(getfilesystemencoding()) | ||
) | ||
|
||
def test_load_verify_directory_unicode_capath(self, tmpfile): | ||
""" | ||
`Context.load_verify_locations` accepts a directory name as a `unicode` | ||
instance and uses the certificates within for verification purposes. | ||
""" | ||
self._load_verify_directory_locations_capath( | ||
tmpfile.decode(getfilesystemencoding()) + NON_ASCII | ||
) | ||
if pathtype == "unicode_path": | ||
tmpfile += NON_ASCII.encode(getfilesystemencoding()) | ||
if argtype == "unicode_arg": | ||
tmpfile = tmpfile.decode(getfilesystemencoding()) | ||
self._load_verify_directory_locations_capath(tmpfile) | ||
|
||
def test_load_verify_locations_wrong_args(self): | ||
""" | ||
|
@@ -2838,23 +2845,24 @@ def test_wantWriteError(self): | |
""" | ||
client_socket, server_socket = socket_pair() | ||
# Fill up the client's send buffer so Connection won't be able to write | ||
# anything. Only write a single byte at a time so we can be sure we | ||
# anything. Start by sending larger chunks (Windows Socket I/O is slow) | ||
# and continue by writing a single byte at a time so we can be sure we | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This brings this test down from 16s to <20ms on my machine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Socket I/O performance joins VFS performance on my Windows is bad list 😄 |
||
# completely fill the buffer. Even though the socket API is allowed to | ||
# signal a short write via its return value it seems this doesn't | ||
# always happen on all platforms (FreeBSD and OS X particular) for the | ||
# very last bit of available buffer space. | ||
msg = b"x" | ||
for i in range(1024 * 1024 * 64): | ||
try: | ||
client_socket.send(msg) | ||
except error as e: | ||
if e.errno == EWOULDBLOCK: | ||
break | ||
raise | ||
else: | ||
pytest.fail( | ||
"Failed to fill socket buffer, cannot test BIO want write" | ||
) | ||
for msg in [b"x" * 65536, b"x"]: | ||
for i in range(1024 * 1024 * 64): | ||
try: | ||
client_socket.send(msg) | ||
except error as e: | ||
if e.errno == EWOULDBLOCK: | ||
break | ||
raise # pragma: no cover | ||
else: # pragma: no cover | ||
pytest.fail( | ||
"Failed to fill socket buffer, cannot test BIO want write" | ||
) | ||
|
||
ctx = Context(SSLv23_METHOD) | ||
conn = Connection(ctx, client_socket) | ||
|
@@ -3753,13 +3761,16 @@ def test_unexpected_EOF(self): | |
""" | ||
If the connection is lost before an orderly SSL shutdown occurs, | ||
`OpenSSL.SSL.SysCallError` is raised with a message of | ||
"Unexpected EOF". | ||
"Unexpected EOF" (or WSAECONNRESET on Windows). | ||
""" | ||
server_conn, client_conn = loopback() | ||
client_conn.sock_shutdown(SHUT_RDWR) | ||
with pytest.raises(SysCallError) as err: | ||
server_conn.recv(1024) | ||
assert err.value.args == (-1, "Unexpected EOF") | ||
if platform == "win32": | ||
assert err.value.args == (10054, "WSAECONNRESET") | ||
else: | ||
assert err.value.args == (-1, "Unexpected EOF") | ||
|
||
def _check_client_ca_list(self, func): | ||
""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_runopenssl
is also used with binary output, so we can't replace this in there for all invocations.