Change the connect addresses used in some tests to make them work on Windows; weaken the egd() error assertion since the behavior appears to differ between Windows and Linux.
diff --git a/OpenSSL/test/test_rand.py b/OpenSSL/test/test_rand.py
index c8645a5..2849f38 100644
--- a/OpenSSL/test/test_rand.py
+++ b/OpenSSL/test/test_rand.py
@@ -108,10 +108,14 @@
def test_egd_missing(self):
"""
- L{OpenSSL.rand.egd} returns C{0} if the EGD socket passed to it does not
- exist.
+ L{OpenSSL.rand.egd} returns C{0} or C{-1} if the EGD socket passed
+ to it does not exist.
"""
- self.assertEquals(rand.egd(self.mktemp()), 0)
+ result = rand.egd(self.mktemp())
+ expected = (-1, 0)
+ self.assertTrue(
+ result in expected,
+ "%r not in %r" % (result, expected))
def test_cleanup_wrong_args(self):
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index a54b464..1ba80ab 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -4,7 +4,7 @@
Unit tests for L{OpenSSL.SSL}.
"""
-from errno import ECONNREFUSED, EINPROGRESS
+from errno import ECONNREFUSED, EINPROGRESS, EWOULDBLOCK
from sys import platform
from socket import error, socket
from os import makedirs
@@ -917,7 +917,8 @@
port.listen(3)
clientSSL = Connection(Context(TLSv1_METHOD), socket())
- clientSSL.connect(port.getsockname())
+ clientSSL.connect(('127.0.0.1', port.getsockname()[1]))
+ # XXX An assertion? Or something?
def test_connect_ex(self):
@@ -931,8 +932,10 @@
clientSSL = Connection(Context(TLSv1_METHOD), socket())
clientSSL.setblocking(False)
- self.assertEquals(
- clientSSL.connect_ex(port.getsockname()), EINPROGRESS)
+ result = clientSSL.connect_ex(port.getsockname())
+ expected = (EINPROGRESS, EWOULDBLOCK)
+ self.assertTrue(
+ result in expected, "%r not in %r" % (result, expected))
def test_accept_wrong_args(self):
@@ -958,7 +961,10 @@
portSSL.listen(3)
clientSSL = Connection(Context(TLSv1_METHOD), socket())
- clientSSL.connect(portSSL.getsockname())
+
+ # Calling portSSL.getsockname() here to get the server IP address sounds
+ # great, but frequently fails on Windows.
+ clientSSL.connect(('127.0.0.1', portSSL.getsockname()[1]))
serverSSL, address = portSSL.accept()