(self)
| 50 | poller.unregister(s2) |
| 51 | |
| 52 | def test_reqrep(self): |
| 53 | s1, s2 = self.create_bound_pair(zmq.REP, zmq.REQ) |
| 54 | |
| 55 | # Sleep to allow sockets to connect. |
| 56 | wait() |
| 57 | |
| 58 | poller = self.Poller() |
| 59 | poller.register(s1, zmq.POLLIN | zmq.POLLOUT) |
| 60 | poller.register(s2, zmq.POLLIN | zmq.POLLOUT) |
| 61 | |
| 62 | # Make sure that s1 is in state 0 and s2 is in POLLOUT |
| 63 | socks = dict(poller.poll()) |
| 64 | assert s1 not in socks |
| 65 | assert socks[s2] == zmq.POLLOUT |
| 66 | |
| 67 | # Make sure that s2 goes immediately into state 0 after send. |
| 68 | s2.send(b'msg1') |
| 69 | socks = dict(poller.poll()) |
| 70 | assert s2 not in socks |
| 71 | |
| 72 | # Make sure that s1 goes into POLLIN state after a time.sleep(). |
| 73 | time.sleep(0.5) |
| 74 | socks = dict(poller.poll()) |
| 75 | assert socks[s1] == zmq.POLLIN |
| 76 | |
| 77 | # Make sure that s1 goes into POLLOUT after recv. |
| 78 | s1.recv() |
| 79 | socks = dict(poller.poll()) |
| 80 | assert socks[s1] == zmq.POLLOUT |
| 81 | |
| 82 | # Make sure s1 goes into state 0 after send. |
| 83 | s1.send(b'msg2') |
| 84 | socks = dict(poller.poll()) |
| 85 | assert s1 not in socks |
| 86 | |
| 87 | # Wait and then see that s2 is in POLLIN. |
| 88 | time.sleep(0.5) |
| 89 | socks = dict(poller.poll()) |
| 90 | assert socks[s2] == zmq.POLLIN |
| 91 | |
| 92 | # Make sure that s2 is in POLLOUT after recv. |
| 93 | s2.recv() |
| 94 | socks = dict(poller.poll()) |
| 95 | assert socks[s2] == zmq.POLLOUT |
| 96 | |
| 97 | poller.unregister(s1) |
| 98 | poller.unregister(s2) |
| 99 | |
| 100 | def test_no_events(self): |
| 101 | s1, s2 = self.create_bound_pair(zmq.PAIR, zmq.PAIR) |
nothing calls this directly
no test coverage detected