Use proper skips and assert* methods in test_asyncore.

This commit is contained in:
Ezio Melotti 2010-07-27 22:03:33 +00:00
parent f1046ca817
commit 63c4640327

View file

@ -118,7 +118,7 @@ class HelperFunctionTests(unittest.TestCase):
# http://mail.python.org/pipermail/python-list/2001-October/109973.html) # http://mail.python.org/pipermail/python-list/2001-October/109973.html)
# These constants should be present as long as poll is available # These constants should be present as long as poll is available
if hasattr(select, 'poll'): @unittest.skipUnless(hasattr(select, 'poll'), 'select.poll required')
def test_readwrite(self): def test_readwrite(self):
# Check that correct methods are called by readwrite() # Check that correct methods are called by readwrite()
@ -259,7 +259,7 @@ class DispatcherTests(unittest.TestCase):
sys.stderr = stderr sys.stderr = stderr
lines = fp.getvalue().splitlines() lines = fp.getvalue().splitlines()
self.assertEquals(lines, ['log: %s' % l1, 'log: %s' % l2]) self.assertEqual(lines, ['log: %s' % l1, 'log: %s' % l2])
def test_log_info(self): def test_log_info(self):
d = asyncore.dispatcher() d = asyncore.dispatcher()
@ -281,7 +281,7 @@ class DispatcherTests(unittest.TestCase):
lines = fp.getvalue().splitlines() lines = fp.getvalue().splitlines()
expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3] expected = ['EGGS: %s' % l1, 'info: %s' % l2, 'SPAM: %s' % l3]
self.assertEquals(lines, expected) self.assertEqual(lines, expected)
def test_unhandled(self): def test_unhandled(self):
d = asyncore.dispatcher() d = asyncore.dispatcher()
@ -306,7 +306,7 @@ class DispatcherTests(unittest.TestCase):
'warning: unhandled write event', 'warning: unhandled write event',
'warning: unhandled connect event', 'warning: unhandled connect event',
'warning: unhandled accept event'] 'warning: unhandled accept event']
self.assertEquals(lines, expected) self.assertEqual(lines, expected)
def test_issue_8594(self): def test_issue_8594(self):
# XXX - this test is supposed to be removed in next major Python # XXX - this test is supposed to be removed in next major Python
@ -322,7 +322,7 @@ class DispatcherTests(unittest.TestCase):
warnings.simplefilter("always") warnings.simplefilter("always")
family = d.family family = d.family
self.assertEqual(family, socket.AF_INET) self.assertEqual(family, socket.AF_INET)
self.assertTrue(len(w) == 1) self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[0].category, DeprecationWarning)) self.assertTrue(issubclass(w[0].category, DeprecationWarning))
def test_strerror(self): def test_strerror(self):
@ -331,7 +331,7 @@ class DispatcherTests(unittest.TestCase):
if hasattr(os, 'strerror'): if hasattr(os, 'strerror'):
self.assertEqual(err, os.strerror(errno.EPERM)) self.assertEqual(err, os.strerror(errno.EPERM))
err = asyncore._strerror(-1) err = asyncore._strerror(-1)
self.assertTrue("unknown error" in err.lower()) self.assertIn("unknown error", err.lower())
class dispatcherwithsend_noread(asyncore.dispatcher_with_send): class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
@ -394,7 +394,8 @@ class DispatcherWithSendTests(unittest.TestCase):
class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests): class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
usepoll = True usepoll = True
if hasattr(asyncore, 'file_wrapper'): @unittest.skipUnless(hasattr(asyncore, 'file_wrapper'),
'asyncore.file_wrapper required')
class FileWrapperTest(unittest.TestCase): class FileWrapperTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.d = b"It's not dead, it's sleeping!" self.d = b"It's not dead, it's sleeping!"