Commit 02f69f69 authored by Trent Nelson's avatar Trent Nelson

Issue #16274: revert r79813:90a46f8943d0 changes to asyncore/test_asyncore.

The backport from 3.2 included a few things not appropriate for 2.7.
parent 0622f6c1
...@@ -515,13 +515,7 @@ class dispatcher: ...@@ -515,13 +515,7 @@ class dispatcher:
self.log_info('unhandled connect event', 'warning') self.log_info('unhandled connect event', 'warning')
def handle_accept(self): def handle_accept(self):
pair = self.accept() self.log_info('unhandled accept event', 'warning')
if pair is not None:
self.handle_accepted(*pair)
def handle_accepted(self, sock, addr):
sock.close()
self.log_info('unhandled accepted event', 'warning')
def handle_close(self): def handle_close(self):
self.log_info('unhandled close event', 'warning') self.log_info('unhandled close event', 'warning')
......
...@@ -296,6 +296,7 @@ class DispatcherTests(unittest.TestCase): ...@@ -296,6 +296,7 @@ class DispatcherTests(unittest.TestCase):
d.handle_read() d.handle_read()
d.handle_write() d.handle_write()
d.handle_connect() d.handle_connect()
d.handle_accept()
finally: finally:
sys.stdout = stdout sys.stdout = stdout
...@@ -303,7 +304,8 @@ class DispatcherTests(unittest.TestCase): ...@@ -303,7 +304,8 @@ class DispatcherTests(unittest.TestCase):
expected = ['warning: unhandled incoming priority event', expected = ['warning: unhandled incoming priority event',
'warning: unhandled read event', 'warning: unhandled read event',
'warning: unhandled write event', 'warning: unhandled write event',
'warning: unhandled connect event'] 'warning: unhandled connect event',
'warning: unhandled accept event']
self.assertEqual(lines, expected) self.assertEqual(lines, expected)
def test_issue_8594(self): def test_issue_8594(self):
...@@ -451,9 +453,6 @@ class BaseTestHandler(asyncore.dispatcher): ...@@ -451,9 +453,6 @@ class BaseTestHandler(asyncore.dispatcher):
def handle_accept(self): def handle_accept(self):
raise Exception("handle_accept not supposed to be called") raise Exception("handle_accept not supposed to be called")
def handle_accepted(self):
raise Exception("handle_accepted not supposed to be called")
def handle_connect(self): def handle_connect(self):
raise Exception("handle_connect not supposed to be called") raise Exception("handle_connect not supposed to be called")
...@@ -484,7 +483,8 @@ class TCPServer(asyncore.dispatcher): ...@@ -484,7 +483,8 @@ class TCPServer(asyncore.dispatcher):
def address(self): def address(self):
return self.socket.getsockname()[:2] return self.socket.getsockname()[:2]
def handle_accepted(self, sock, addr): def handle_accept(self):
sock, addr = self.accept()
self.handler(sock) self.handler(sock)
def handle_error(self): def handle_error(self):
...@@ -548,29 +548,6 @@ class BaseTestAPI(unittest.TestCase): ...@@ -548,29 +548,6 @@ class BaseTestAPI(unittest.TestCase):
client = BaseClient(server.address) client = BaseClient(server.address)
self.loop_waiting_for_flag(server) self.loop_waiting_for_flag(server)
def test_handle_accepted(self):
# make sure handle_accepted() is called when a client connects
class TestListener(BaseTestHandler):
def __init__(self):
BaseTestHandler.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.bind((HOST, 0))
self.listen(5)
self.address = self.socket.getsockname()[:2]
def handle_accept(self):
asyncore.dispatcher.handle_accept(self)
def handle_accepted(self, sock, addr):
sock.close()
self.flag = True
server = TestListener()
client = BaseClient(server.address)
self.loop_waiting_for_flag(server)
def test_handle_read(self): def test_handle_read(self):
# make sure handle_read is called on data received # make sure handle_read is called on data received
...@@ -694,8 +671,7 @@ class BaseTestAPI(unittest.TestCase): ...@@ -694,8 +671,7 @@ class BaseTestAPI(unittest.TestCase):
s = asyncore.dispatcher() s = asyncore.dispatcher()
s.create_socket(socket.AF_INET, socket.SOCK_STREAM) s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.assertEqual(s.socket.family, socket.AF_INET) self.assertEqual(s.socket.family, socket.AF_INET)
SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', 0) self.assertEqual(s.socket.type, socket.SOCK_STREAM)
self.assertEqual(s.socket.type, socket.SOCK_STREAM | SOCK_NONBLOCK)
def test_bind(self): def test_bind(self):
s1 = asyncore.dispatcher() s1 = asyncore.dispatcher()
...@@ -721,7 +697,6 @@ class BaseTestAPI(unittest.TestCase): ...@@ -721,7 +697,6 @@ class BaseTestAPI(unittest.TestCase):
s = asyncore.dispatcher(socket.socket()) s = asyncore.dispatcher(socket.socket())
self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET, self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR)) socket.SO_REUSEADDR))
s.socket.close()
s.create_socket(socket.AF_INET, socket.SOCK_STREAM) s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
s.set_reuse_addr() s.set_reuse_addr()
self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET, self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment