mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
[3.7] bpo-32861: urllib.robotparser fix incomplete __str__ methods. (GH-5711) (GH-6795)
The urllib.robotparser's __str__ representation now includes wildcard
entries and the "Crawl-delay" and "Request-rate" fields.
(cherry picked from commit bd08a0af2d
)
Co-authored-by: Michael Lazar <lazar.michael22@gmail.com>
This commit is contained in:
parent
67d1968a41
commit
c3fa1f2b93
3 changed files with 43 additions and 5 deletions
|
@ -246,6 +246,33 @@ 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