Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(261232)

Unified Diff: Lib/test/test_socket.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_slice.py ('k') | Lib/test/test_ssl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_socket.py Fri Feb 07 17:53:13 2014 +0100
+++ b/Lib/test/test_socket.py Fri Feb 07 23:40:05 2014 +0200
@@ -743,7 +743,7 @@
except OSError:
# Probably name lookup wasn't set up right; skip this test
self.skipTest('name lookup failure')
- self.assertTrue(ip.find('.') >= 0, "Error resolving host to ip.")
+ self.assertIn('.', ip, "Error resolving host to ip.")
try:
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
except OSError:
@@ -1113,7 +1113,7 @@
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.addCleanup(sock.close)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
- self.assertFalse(reuse != 0, "initial mode is reuse")
+ self.assertEqual(reuse, 0, "initial mode is reuse")
def testSetSockOpt(self):
# Testing setsockopt()
@@ -1121,7 +1121,7 @@
self.addCleanup(sock.close)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR)
- self.assertFalse(reuse == 0, "failed to set reuse mode")
+ self.assertNotEqual(reuse, 0, "failed to set reuse mode")
def testSendAfterClose(self):
# testing send() after close() with timeout
@@ -3745,7 +3745,7 @@
except OSError:
pass
end = time.time()
- self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
+ self.assertLess(end - start, 1.0, "Error setting non-blocking mode.")
def _testSetBlocking(self):
pass
@@ -3780,7 +3780,7 @@
except OSError:
pass
end = time.time()
- self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.")
+ self.assertLess(end - start, 1.0, "Error creating with non-blocking mode.")
def _testInitNonBlocking(self):
pass
@@ -4386,7 +4386,7 @@
testTimeoutDefault = _justAccept
def _testTimeoutDefault(self):
# passing no explicit timeout uses socket's global default
- self.assertTrue(socket.getdefaulttimeout() is None)
+ self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(42)
try:
self.cli = socket.create_connection((HOST, self.port))
@@ -4398,7 +4398,7 @@
testTimeoutNone = _justAccept
def _testTimeoutNone(self):
# None timeout means the same as sock.settimeout(None)
- self.assertTrue(socket.getdefaulttimeout() is None)
+ self.assertIsNone(socket.getdefaulttimeout())
socket.setdefaulttimeout(30)
try:
self.cli = socket.create_connection((HOST, self.port), timeout=None)
« no previous file with comments | « Lib/test/test_slice.py ('k') | Lib/test/test_ssl.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+