Exemplo n.º 1
0
 def test_doReadWarningIsRaised(self):
     """
     When an L{IProtocol} implementation that returns a value from its
     C{dataReceived} method, a deprecated warning is emitted.
     """
     skt = FakeSocket("someData")
     protocol = FakeProtocol()
     conn = Connection(skt, protocol)
     conn.doRead()
     warnings = self.flushWarnings([FakeProtocol.dataReceived])
     self.assertEquals(warnings[0]['category'], DeprecationWarning)
     self.assertEquals(
         warnings[0]["message"], "Returning a value other than None from "
         "twisted.internet.test.test_tcp.FakeProtocol.dataReceived "
         "is deprecated since Twisted 11.0.0.")
     self.assertEquals(len(warnings), 1)
Exemplo n.º 2
0
    def test_getWriters(self):
        """
        Check that L{interfaces.IReactorFDSet.getWriters} reflects the actions
        made with L{interfaces.IReactorFDSet.addWriter} and
        L{interfaces.IReactorFDSet.removeWriter}.
        """
        s = socket.socket()
        self.addCleanup(s.close)

        c = Connection(s, protocol.Protocol())
        self.assertNotIn(c, reactor.getWriters())

        reactor.addWriter(c)
        self.assertIn(c, reactor.getWriters())

        reactor.removeWriter(c)
        self.assertNotIn(c, reactor.getWriters())