summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_socket.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-08-13 08:51:18 (GMT)
committerGeorg Brandl <georg@python.org>2009-08-13 08:51:18 (GMT)
commitab91fdef1f1e556203a2eee98ba7d379e4790de9 (patch)
tree6f8f00dc18cc5f2801a675df277c2c595eb85ec8 /Lib/test/test_socket.py
parentef82be368abdea8e8032500e7ecc3a22f5f07851 (diff)
downloadcpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.zip
cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.gz
cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.bz2
Merged revisions 73715 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line convert old fail* assertions to assert* ........
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r--Lib/test/test_socket.py54
1 files changed, 27 insertions, 27 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index e8a9fc4..8313006 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -224,7 +224,7 @@ class GeneralModuleTests(unittest.TestCase):
def test_repr(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.assert_(repr(s).startswith("<socket.socket object"))
+ self.assertTrue(repr(s).startswith("<socket.socket object"))
def test_weakref(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -247,11 +247,11 @@ class GeneralModuleTests(unittest.TestCase):
raise socket.herror
def raise_gaierror(*args, **kwargs):
raise socket.gaierror
- self.failUnlessRaises(socket.error, raise_error,
+ self.assertRaises(socket.error, raise_error,
"Error raising socket exception.")
- self.failUnlessRaises(socket.error, raise_herror,
+ self.assertRaises(socket.error, raise_herror,
"Error raising socket exception.")
- self.failUnlessRaises(socket.error, raise_gaierror,
+ self.assertRaises(socket.error, raise_gaierror,
"Error raising socket exception.")
def testCrucialConstants(self):
@@ -273,7 +273,7 @@ class GeneralModuleTests(unittest.TestCase):
except socket.error:
# Probably name lookup wasn't set up right; skip this test
return
- self.assert_(ip.find('.') >= 0, "Error resolving host to ip.")
+ self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.")
try:
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
except socket.error:
@@ -501,7 +501,7 @@ class GeneralModuleTests(unittest.TestCase):
# it reasonable to get the host's addr in addition to 0.0.0.0.
# At least for eCos. This is required for the S/390 to pass.
my_ip_addr = socket.gethostbyname(socket.gethostname())
- self.assert_(name[0] in ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
+ self.assertTrue(name[0] in ("0.0.0.0", my_ip_addr), '%s invalid' % name[0])
self.assertEqual(name[1], port)
def testGetSockOpt(self):
@@ -509,14 +509,14 @@ class GeneralModuleTests(unittest.TestCase):
# We know a socket should start without reuse==0
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
- self.failIf(reuse != 0, "initial mode is reuse")
+ self.assertFalse(reuse != 0, "initial mode is reuse")
def testSetSockOpt(self):
# Testing setsockopt()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
- self.failIf(reuse == 0, "failed to set reuse mode")
+ self.assertFalse(reuse == 0, "failed to set reuse mode")
def testSendAfterClose(self):
# testing send() after close() with timeout
@@ -549,10 +549,10 @@ class GeneralModuleTests(unittest.TestCase):
def test_sock_ioctl(self):
if os.name != "nt":
return
- self.assert_(hasattr(socket.socket, 'ioctl'))
- self.assert_(hasattr(socket, 'SIO_RCVALL'))
- self.assert_(hasattr(socket, 'RCVALL_ON'))
- self.assert_(hasattr(socket, 'RCVALL_OFF'))
+ self.assertTrue(hasattr(socket.socket, 'ioctl'))
+ self.assertTrue(hasattr(socket, 'SIO_RCVALL'))
+ self.assertTrue(hasattr(socket, 'RCVALL_ON'))
+ self.assertTrue(hasattr(socket, 'RCVALL_OFF'))
class BasicTCPTest(SocketConnectedTest):
@@ -724,7 +724,7 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
except socket.error:
pass
end = time.time()
- self.assert_((end - start) < 1.0, "Error setting non-blocking mode.")
+ self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
def _testSetBlocking(self):
pass
@@ -801,7 +801,7 @@ class FileObjectClassTestCase(SocketConnectedTest):
def tearDown(self):
self.serv_file.close()
- self.assert_(self.serv_file.closed)
+ self.assertTrue(self.serv_file.closed)
self.serv_file = None
SocketConnectedTest.tearDown(self)
@@ -811,7 +811,7 @@ class FileObjectClassTestCase(SocketConnectedTest):
def clientTearDown(self):
self.cli_file.close()
- self.assert_(self.cli_file.closed)
+ self.assertTrue(self.cli_file.closed)
self.cli_file = None
SocketConnectedTest.clientTearDown(self)
@@ -879,10 +879,10 @@ class FileObjectClassTestCase(SocketConnectedTest):
self.cli_file.flush()
def testClosedAttr(self):
- self.assert_(not self.serv_file.closed)
+ self.assertTrue(not self.serv_file.closed)
def _testClosedAttr(self):
- self.assert_(not self.cli_file.closed)
+ self.assertTrue(not self.cli_file.closed)
def testAttributes(self):
self.assertEqual(self.serv_file.mode, 'rb')
@@ -977,7 +977,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
def testWithoutServer(self):
port = support.find_unused_port()
- self.failUnlessRaises(
+ self.assertRaises(
socket.error,
lambda: socket.create_connection((HOST, port))
)
@@ -1007,7 +1007,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
testTimeoutDefault = _justAccept
def _testTimeoutDefault(self):
# passing no explicit timeout uses socket's global default
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(42)
try:
self.cli = socket.create_connection((HOST, self.port))
@@ -1018,7 +1018,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
testTimeoutNone = _justAccept
def _testTimeoutNone(self):
# None timeout means the same as sock.settimeout(None)
- self.assert_(socket.getdefaulttimeout() is None)
+ self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
self.cli = socket.create_connection((HOST, self.port), timeout=None)
@@ -1063,7 +1063,7 @@ class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest):
def _testOutsideTimeout(self):
self.cli = sock = socket.create_connection((HOST, self.port), timeout=1)
- self.failUnlessRaises(socket.timeout, lambda: sock.recv(5))
+ self.assertRaises(socket.timeout, lambda: sock.recv(5))
class TCPTimeoutTest(SocketTCPTest):
@@ -1072,7 +1072,7 @@ class TCPTimeoutTest(SocketTCPTest):
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.accept()
- self.failUnlessRaises(socket.timeout, raise_timeout,
+ self.assertRaises(socket.timeout, raise_timeout,
"Error generating a timeout exception (TCP)")
def testTimeoutZero(self):
@@ -1129,7 +1129,7 @@ class UDPTimeoutTest(SocketTCPTest):
def raise_timeout(*args, **kwargs):
self.serv.settimeout(1.0)
self.serv.recv(1024)
- self.failUnlessRaises(socket.timeout, raise_timeout,
+ self.assertRaises(socket.timeout, raise_timeout,
"Error generating a timeout exception (UDP)")
def testTimeoutZero(self):
@@ -1149,10 +1149,10 @@ class UDPTimeoutTest(SocketTCPTest):
class TestExceptions(unittest.TestCase):
def testExceptionTree(self):
- self.assert_(issubclass(socket.error, Exception))
- self.assert_(issubclass(socket.herror, socket.error))
- self.assert_(issubclass(socket.gaierror, socket.error))
- self.assert_(issubclass(socket.timeout, socket.error))
+ self.assertTrue(issubclass(socket.error, Exception))
+ self.assertTrue(issubclass(socket.herror, socket.error))
+ self.assertTrue(issubclass(socket.gaierror, socket.error))
+ self.assertTrue(issubclass(socket.timeout, socket.error))
class TestLinuxAbstractNamespace(unittest.TestCase):