def test_refusedEnableRequest(self):
        """
        If the peer refuses to enable an option we request it to enable, the
        L{Deferred} returned by L{TelnetProtocol.do} fires with an
        L{OptionRefused} L{Failure}.
        """
        # Try to enable an option through the user-level API.  This returns a
        # Deferred that fires when negotiation about the option finishes.  Make
        # sure it fires, make sure state gets updated properly, make sure the
        # result indicates the option was enabled.
        self.p.protocol.remoteEnableable = (b'\x42',)
        d = self.p.do(b'\x42')

        self.assertEqual(self.t.value(), telnet.IAC + telnet.DO + b'\x42')

        s = self.p.getOptionState(b'\x42')
        self.assertEqual(s.him.state, 'no')
        self.assertEqual(s.us.state, 'no')
        self.assertTrue(s.him.negotiating)
        self.assertFalse(s.us.negotiating)

        self.p.dataReceived(telnet.IAC + telnet.WONT + b'\x42')

        d = self.assertFailure(d, telnet.OptionRefused)
        d.addCallback(lambda ignored: self._enabledHelper(self.p.protocol))
        d.addCallback(
            lambda ignored: self.assertFalse(s.him.negotiating))
        return d

        If the peer refuses to enable an option we request it to enable, the
        L{Deferred} returned by L{TelnetProtocol.do} fires with an
        L{OptionRefused} L{Failure}.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_telnet.py