core: make Receiver.to_sender() use Router.myself().
This commit is contained in:
parent
581b1e4191
commit
fcc403cc2f
|
@ -830,8 +830,7 @@ class Receiver(object):
|
|||
for msg in recv:
|
||||
print(msg)
|
||||
"""
|
||||
context = Context(self.router, mitogen.context_id)
|
||||
return Sender(context, self.handle)
|
||||
return Sender(self.router.myself(), self.handle)
|
||||
|
||||
def _on_receive(self, msg):
|
||||
"""
|
||||
|
|
|
@ -146,5 +146,14 @@ class OnReceiveTest(testlib.RouterMixin, testlib.TestCase):
|
|||
# TODO: what happens to a Select subscribed to the receiver in this case?
|
||||
|
||||
|
||||
class ToSenderTest(testlib.RouterMixin, testlib.TestCase):
|
||||
klass = mitogen.core.Receiver
|
||||
|
||||
def test_returned_context(self):
|
||||
myself = self.router.myself()
|
||||
recv = self.klass(self.router)
|
||||
self.assertEquals(myself, recv.to_sender().context)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
||||
|
|
|
@ -212,6 +212,14 @@ class AddHandlerTest(testlib.TestCase):
|
|||
router.broker.join()
|
||||
|
||||
|
||||
class MyselfTest(testlib.RouterMixin, testlib.TestCase):
|
||||
def test_myself(self):
|
||||
myself = self.router.myself()
|
||||
self.assertEquals(myself.context_id, mitogen.context_id)
|
||||
# TODO: context should know its own name too.
|
||||
self.assertEquals(myself.name, 'self')
|
||||
|
||||
|
||||
class MessageSizeTest(testlib.BrokerMixin, testlib.TestCase):
|
||||
klass = mitogen.master.Router
|
||||
|
||||
|
|
Loading…
Reference in New Issue