def test_putNotQuiescent(self):
        """
        If a non-quiescent connection is put back in the cache, an error is
        logged.
        """
        protocol = StubHTTPProtocol()
        # By default state is QUIESCENT
        self.assertEqual(protocol.state, "QUIESCENT")

        logObserver = EventLoggingObserver.createWithCleanup(
            self,
            globalLogPublisher
        )

        protocol.state = "NOTQUIESCENT"
        self.pool._putConnection(("http", b"example.com", 80), protocol)
        self.assertEquals(1, len(logObserver))

        event = logObserver[0]
        f = event["log_failure"]

        self.assertIsInstance(f.value, RuntimeError)
        self.assertEqual(
            f.getErrorMessage(),
            "BUG: Non-quiescent protocol added to connection pool.")
        self.assertIdentical(None, self.pool._connections.get(
                ("http", b"example.com", 80)))
        self.flushLoggedErrors(RuntimeError)

        If a non-quiescent connection is put back in the cache, an error is
        logged.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_agent.py