r46875 - turns out those un-covered lines of code ...

glyph-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: glyph
Date: Mon Feb 29 14:50:28 2016
New Revision: 46875

Modified:
   branches/persistent-client-service-4735-5/twisted/application/internet.py
   branches/persistent-client-service-4735-5/twisted/application/test/test_internet.py

Log:
turns out those un-covered lines of code ...

... actually *un*-implement the desired behavior, so to make the test
pass we need to remove them.

Modified: branches/persistent-client-service-4735-5/twisted/application/internet.py
==============================================================================
--- branches/persistent-client-service-4735-5/twisted/application/internet.py	(original)
+++ branches/persistent-client-service-4735-5/twisted/application/internet.py	Mon Feb 29 14:50:28 2016
@@ -423,11 +423,6 @@
         self._protocol = protocol
         self._lostNotification = lostNotification
 
-        for iface in [interfaces.IHalfCloseableProtocol,
-                      interfaces.IFileDescriptorReceiver]:
-            if iface.providedBy(self._protocol):
-                directlyProvides(self, iface)
-
 
     def connectionLost(self, reason):
         """

Modified: branches/persistent-client-service-4735-5/twisted/application/test/test_internet.py
==============================================================================
--- branches/persistent-client-service-4735-5/twisted/application/test/test_internet.py	(original)
+++ branches/persistent-client-service-4735-5/twisted/application/test/test_internet.py	Mon Feb 29 14:50:28 2016
@@ -23,7 +23,8 @@
     StreamServerEndpointService, TimerService, ClientService)
 from twisted.internet.defer import Deferred, CancelledError
 from twisted.internet.interfaces import (
-    IStreamServerEndpoint, IStreamClientEndpoint, IListeningPort
+    IStreamServerEndpoint, IStreamClientEndpoint, IListeningPort,
+    IHalfCloseableProtocol, IFileDescriptorReceiver
 )
 from twisted.internet import task
 from twisted.python.failure import Failure
@@ -496,7 +497,8 @@
     Tests for L{ClientService}.
     """
 
-    def makeReconnector(self, fireImmediately=True, startService=True, **kw):
+    def makeReconnector(self, fireImmediately=True, startService=True,
+                        protocolType=Protocol, **kw):
         """
         Create a L{ClientService} along with a L{ConnectInformation} indicating
         the connections in progress on its endpoint.
@@ -520,7 +522,7 @@
         nkw.update(kw)
         cq, endpoint = endpointForTesting(fireImmediately=fireImmediately)
         class RememberingFactory(Factory, object):
-            protocol = Protocol
+            protocol = protocolType
             def buildProtocol(self, addr):
                 result = super(RememberingFactory, self).buildProtocol(addr)
                 cq.applicationProtocols.append(result)
@@ -563,6 +565,23 @@
         self.successResultOf(d)
 
 
+    def test_interfacesForTransport(self):
+        """
+        If the protocol objects returned by the factory given to
+        L{ClientService} provide special "marker" interfaces for their
+        transport - L{IHalfCloseableProtocol} or L{IFileDescriptorReceiver} -
+        those interfaces will be provided by the protocol objects passed on to
+        the reactor.
+        """
+        @implementer(IHalfCloseableProtocol, IFileDescriptorReceiver)
+        class FancyProtocol(Protocol, object):
+            "Provider of various interfaces."
+        cq, service = self.makeReconnector(protocolType=FancyProtocol)
+        reactorFacing = cq.constructedProtocols[0]
+        self.assertTrue(IFileDescriptorReceiver.providedBy(reactorFacing))
+        self.assertTrue(IHalfCloseableProtocol.providedBy(reactorFacing))
+
+
     def test_stopServiceWhileRetrying(self):
         """
         When the service is stopped while retrying, the retry is cancelled.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.