mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
bpo-32861: urllib.robotparser fix incomplete __str__ methods. (GH-5711)
The urllib.robotparser's __str__ representation now includes wildcard entries and the "Crawl-delay" and "Request-rate" fields. Also removes extra newlines that were being appended to the end of the string.
This commit is contained in:
parent
5c0d462689
commit
bd08a0af2d
3 changed files with 42 additions and 5 deletions
|
@ -246,6 +246,32 @@ Disallow: /cyberworld/map/
|
|||
bad = ['/cyberworld/map/index.html']
|
||||
|
||||
|
||||
class StringFormattingTest(BaseRobotTest, unittest.TestCase):
|
||||
robots_txt = """\
|
||||
User-agent: *
|
||||
Crawl-delay: 1
|
||||
Request-rate: 3/15
|
||||
Disallow: /cyberworld/map/ # This is an infinite virtual URL space
|
||||
|
||||
# Cybermapper knows where to go.
|
||||
User-agent: cybermapper
|
||||
Disallow: /some/path
|
||||
"""
|
||||
|
||||
expected_output = """\
|
||||
User-agent: cybermapper
|
||||
Disallow: /some/path
|
||||
|
||||
User-agent: *
|
||||
Crawl-delay: 1
|
||||
Request-rate: 3/15
|
||||
Disallow: /cyberworld/map/\
|
||||
"""
|
||||
|
||||
def test_string_formatting(self):
|
||||
self.assertEqual(str(self.parser), self.expected_output)
|
||||
|
||||
|
||||
class RobotHandler(BaseHTTPRequestHandler):
|
||||
|
||||
def do_GET(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue