Ticket #6391: 6391_improve2.patch

File 6391_improve2.patch, 2.3 KB (added by eddie, 7 years ago)

I modified the indention.

  • twisted/web/http.py

     
    791791
    792792
    793793    def __repr__(self):
    794         return '<%s %s %s>'% (self.method, self.uri, self.clientproto)
     794        """
     795        Return the class name, address, method, uri and client protocol of the
     796        C{Request} instance as a C{string} in the form
     797            <CLASSNAME at ADDRESS method=METHOD uri=URI clientproto=CLIENTPROTOCOL>
    795798
     799        @return: C{string} in the form
     800            <CLASSNAME at ADDRESS method=METHOD uri=URI clientproto=CLIENTPROTOCOL>
     801        @rtype: C{string}
     802        """
     803        return '<%s.%s at 0x%x method=%s uri=%s clientproto=%s>' % (
     804            self.__module__,
     805            self.__class__.__name__,
     806            id(self),
     807            nativeString(self.method),
     808            nativeString(self.uri),
     809            nativeString(self.clientproto))
     810
    796811    def process(self):
    797812        """
    798813        Override in subclasses.
  • twisted/web/test/test_http.py

     
    16531653        self.assertRaises(RuntimeError, req.finish)
    16541654
    16551655
     1656    def test_repr(self):
     1657        """
     1658        L{Request.__repr__} returns the class name, address, uri and client protocol of
     1659        the C{Request} instance as a C{string} in the form
     1660            <ClASSNAME at ADDRESS method=METHOD uri=URI clientproto=CLIENTPROTOCOL>
     1661        """
    16561662
     1663        request = http.Request(DummyChannel(), False)
     1664        self.assertEqual(repr(request),
     1665            '<twisted.web.http.Request at 0x%x method=(no method yet) uri=(no uri yet) clientproto=(no clientproto yet)>' % (
     1666            id(request),))
     1667        request.clientproto = b'HTTP/1.0'
     1668        request.method = b'GET'
     1669        request.uri = b'/foo/bar'
     1670        self.assertEqual(repr(request),
     1671            '<twisted.web.http.Request at 0x%x method=GET uri=/foo/bar clientproto=HTTP/1.0>' % (
     1672            id(request),))
     1673
     1674
     1675
    16571676class MultilineHeadersTestCase(unittest.TestCase):
    16581677    """
    16591678    Tests to exercise handling of multiline headers by L{HTTPClient}.  RFCs 1945