Issue #6419: Fix a test_kqueue failure on some BSD flavors.

parent 56bb8b9b
...@@ -96,11 +96,6 @@ class TestKQueue(unittest.TestCase): ...@@ -96,11 +96,6 @@ class TestKQueue(unittest.TestCase):
pass # FreeBSD doesn't raise an exception here pass # FreeBSD doesn't raise an exception here
server, addr = serverSocket.accept() server, addr = serverSocket.accept()
if sys.platform.startswith("darwin"):
flags = select.KQ_EV_ADD | select.KQ_EV_ENABLE
else:
flags = 0
kq = select.kqueue() kq = select.kqueue()
kq2 = select.kqueue.fromfd(kq.fileno()) kq2 = select.kqueue.fromfd(kq.fileno())
...@@ -122,11 +117,10 @@ class TestKQueue(unittest.TestCase): ...@@ -122,11 +117,10 @@ class TestKQueue(unittest.TestCase):
kq2.control([ev], 0) kq2.control([ev], 0)
events = kq.control(None, 4, 1) events = kq.control(None, 4, 1)
events = [(e.ident, e.filter, e.flags) for e in events] events = set((e.ident, e.filter) for e in events)
events.sort() self.assertEqual(events, set([
self.assertEqual(events, [ (client.fileno(), select.KQ_FILTER_WRITE),
(client.fileno(), select.KQ_FILTER_WRITE, flags), (server.fileno(), select.KQ_FILTER_WRITE)]))
(server.fileno(), select.KQ_FILTER_WRITE, flags)])
client.send("Hello!") client.send("Hello!")
server.send("world!!!") server.send("world!!!")
...@@ -140,14 +134,12 @@ class TestKQueue(unittest.TestCase): ...@@ -140,14 +134,12 @@ class TestKQueue(unittest.TestCase):
else: else:
self.fail('timeout waiting for event notifications') self.fail('timeout waiting for event notifications')
events = [(e.ident, e.filter, e.flags) for e in events] events = set((e.ident, e.filter) for e in events)
events.sort() self.assertEqual(events, set([
(client.fileno(), select.KQ_FILTER_WRITE),
self.assertEqual(events, [ (client.fileno(), select.KQ_FILTER_READ),
(client.fileno(), select.KQ_FILTER_WRITE, flags), (server.fileno(), select.KQ_FILTER_WRITE),
(client.fileno(), select.KQ_FILTER_READ, flags), (server.fileno(), select.KQ_FILTER_READ)]))
(server.fileno(), select.KQ_FILTER_WRITE, flags),
(server.fileno(), select.KQ_FILTER_READ, flags)])
# Remove completely client, and server read part # Remove completely client, and server read part
ev = select.kevent(client.fileno(), ev = select.kevent(client.fileno(),
...@@ -164,10 +156,9 @@ class TestKQueue(unittest.TestCase): ...@@ -164,10 +156,9 @@ class TestKQueue(unittest.TestCase):
kq.control([ev], 0, 0) kq.control([ev], 0, 0)
events = kq.control([], 4, 0.99) events = kq.control([], 4, 0.99)
events = [(e.ident, e.filter, e.flags) for e in events] events = set((e.ident, e.filter) for e in events)
events.sort() self.assertEqual(events, set([
self.assertEqual(events, [ (server.fileno(), select.KQ_FILTER_WRITE)]))
(server.fileno(), select.KQ_FILTER_WRITE, flags)])
client.close() client.close()
server.close() server.close()
......
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