def test_negativeOneFileDescriptor(self):
        """
        If L{FileDescriptor.fileno} returns C{-1}, the descriptor is removed
        from the reactor.
        """
        reactor = self.buildReactor()

        client, server = self._connectedPair()

        class DisappearingDescriptor(FileDescriptor):
            _fileno = server.fileno()

            _received = b""

            def fileno(self):
                return self._fileno

            def doRead(self):
                self._fileno = -1
                self._received += server.recv(1)
                client.send(b'y')

            def connectionLost(self, reason):
                reactor.stop()

        descriptor = DisappearingDescriptor(reactor)
        reactor.addReader(descriptor)
        client.send(b'x')
        self.runReactor(reactor)
        self.assertEqual(descriptor._received, b"x")

        If L{FileDescriptor.fileno} returns C{-1}, the descriptor is removed
        from the reactor.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/internet/test/test_fdset.py