Selectively enable tests for asyncore.readwrite based on the presence
of poll support in the select module (since this is the only case in which readwrite can be called). [GSoC - Alan McIntyre]
This commit is contained in:
parent
6819210b9e
commit
7f4f41255f
|
@ -106,87 +106,83 @@ class HelperFunctionTests(unittest.TestCase):
|
||||||
asyncore._exception(tr2)
|
asyncore._exception(tr2)
|
||||||
self.assertEqual(tr2.error_handled, True)
|
self.assertEqual(tr2.error_handled, True)
|
||||||
|
|
||||||
## Commented out these tests because test a non-documented function
|
# asyncore.readwrite uses constants in the select module that
|
||||||
## (which is actually public, why it's not documented?). Anyway, the
|
# are not present in Windows systems (see this thread:
|
||||||
## tests *and* the function uses constants in the select module that
|
# http://mail.python.org/pipermail/python-list/2001-October/109973.html)
|
||||||
## are not present in Windows systems (see this thread:
|
# These constants should be present as long as poll is available
|
||||||
## http://mail.python.org/pipermail/python-list/2001-October/109973.html)
|
|
||||||
## Note even that these constants are mentioned in the select
|
if hasattr(select, 'poll'):
|
||||||
## documentation, as a parameter of "poll" method "register", but are
|
def test_readwrite(self):
|
||||||
## not explicit declared as constants of the module.
|
# Check that correct methods are called by readwrite()
|
||||||
## . Facundo Batista
|
|
||||||
##
|
class testobj:
|
||||||
## def test_readwrite(self):
|
def __init__(self):
|
||||||
## # Check that correct methods are called by readwrite()
|
self.read = False
|
||||||
##
|
self.write = False
|
||||||
## class testobj:
|
self.expt = False
|
||||||
## def __init__(self):
|
|
||||||
## self.read = False
|
def handle_read_event(self):
|
||||||
## self.write = False
|
self.read = True
|
||||||
## self.expt = False
|
|
||||||
##
|
def handle_write_event(self):
|
||||||
## def handle_read_event(self):
|
self.write = True
|
||||||
## self.read = True
|
|
||||||
##
|
def handle_expt_event(self):
|
||||||
## def handle_write_event(self):
|
self.expt = True
|
||||||
## self.write = True
|
|
||||||
##
|
def handle_error(self):
|
||||||
## def handle_expt_event(self):
|
self.error_handled = True
|
||||||
## self.expt = True
|
|
||||||
##
|
for flag in (select.POLLIN, select.POLLPRI):
|
||||||
## def handle_error(self):
|
tobj = testobj()
|
||||||
## self.error_handled = True
|
self.assertEqual(tobj.read, False)
|
||||||
##
|
asyncore.readwrite(tobj, flag)
|
||||||
## for flag in (select.POLLIN, select.POLLPRI):
|
self.assertEqual(tobj.read, True)
|
||||||
## tobj = testobj()
|
|
||||||
## self.assertEqual(tobj.read, False)
|
# check that ExitNow exceptions in the object handler method
|
||||||
## asyncore.readwrite(tobj, flag)
|
# bubbles all the way up through asyncore readwrite call
|
||||||
## self.assertEqual(tobj.read, True)
|
tr1 = exitingdummy()
|
||||||
##
|
self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag)
|
||||||
## # check that ExitNow exceptions in the object handler method
|
|
||||||
## # bubbles all the way up through asyncore readwrite call
|
# check that an exception other than ExitNow in the object handler
|
||||||
## tr1 = exitingdummy()
|
# method causes the handle_error method to get called
|
||||||
## self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag)
|
tr2 = crashingdummy()
|
||||||
##
|
asyncore.readwrite(tr2, flag)
|
||||||
## # check that an exception other than ExitNow in the object handler
|
self.assertEqual(tr2.error_handled, True)
|
||||||
## # method causes the handle_error method to get called
|
|
||||||
## tr2 = crashingdummy()
|
tobj = testobj()
|
||||||
## asyncore.readwrite(tr2, flag)
|
self.assertEqual(tobj.write, False)
|
||||||
## self.assertEqual(tr2.error_handled, True)
|
asyncore.readwrite(tobj, select.POLLOUT)
|
||||||
##
|
self.assertEqual(tobj.write, True)
|
||||||
## tobj = testobj()
|
|
||||||
## self.assertEqual(tobj.write, False)
|
# check that ExitNow exceptions in the object handler method
|
||||||
## asyncore.readwrite(tobj, select.POLLOUT)
|
# bubbles all the way up through asyncore readwrite call
|
||||||
## self.assertEqual(tobj.write, True)
|
tr1 = exitingdummy()
|
||||||
##
|
self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1,
|
||||||
## # check that ExitNow exceptions in the object handler method
|
select.POLLOUT)
|
||||||
## # bubbles all the way up through asyncore readwrite call
|
|
||||||
## tr1 = exitingdummy()
|
# check that an exception other than ExitNow in the object handler
|
||||||
## self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1,
|
# method causes the handle_error method to get called
|
||||||
## select.POLLOUT)
|
tr2 = crashingdummy()
|
||||||
##
|
asyncore.readwrite(tr2, select.POLLOUT)
|
||||||
## # check that an exception other than ExitNow in the object handler
|
self.assertEqual(tr2.error_handled, True)
|
||||||
## # method causes the handle_error method to get called
|
|
||||||
## tr2 = crashingdummy()
|
for flag in (select.POLLERR, select.POLLHUP, select.POLLNVAL):
|
||||||
## asyncore.readwrite(tr2, select.POLLOUT)
|
tobj = testobj()
|
||||||
## self.assertEqual(tr2.error_handled, True)
|
self.assertEqual(tobj.expt, False)
|
||||||
##
|
asyncore.readwrite(tobj, flag)
|
||||||
## for flag in (select.POLLERR, select.POLLHUP, select.POLLNVAL):
|
self.assertEqual(tobj.expt, True)
|
||||||
## tobj = testobj()
|
|
||||||
## self.assertEqual(tobj.expt, False)
|
# check that ExitNow exceptions in the object handler method
|
||||||
## asyncore.readwrite(tobj, flag)
|
# bubbles all the way up through asyncore readwrite calls
|
||||||
## self.assertEqual(tobj.expt, True)
|
tr1 = exitingdummy()
|
||||||
##
|
self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag)
|
||||||
## # check that ExitNow exceptions in the object handler method
|
|
||||||
## # bubbles all the way up through asyncore readwrite calls
|
# check that an exception other than ExitNow in the object handler
|
||||||
## tr1 = exitingdummy()
|
# method causes the handle_error method to get called
|
||||||
## self.assertRaises(asyncore.ExitNow, asyncore.readwrite, tr1, flag)
|
tr2 = crashingdummy()
|
||||||
##
|
asyncore.readwrite(tr2, flag)
|
||||||
## # check that an exception other than ExitNow in the object handler
|
self.assertEqual(tr2.error_handled, True)
|
||||||
## # method causes the handle_error method to get called
|
|
||||||
## tr2 = crashingdummy()
|
|
||||||
## asyncore.readwrite(tr2, flag)
|
|
||||||
## self.assertEqual(tr2.error_handled, True)
|
|
||||||
|
|
||||||
def test_closeall(self):
|
def test_closeall(self):
|
||||||
self.closeall_check(False)
|
self.closeall_check(False)
|
||||||
|
|
Loading…
Reference in New Issue