diff options
author | Michael Lazar <lazar.michael22@gmail.com> | 2018-05-14 14:10:41 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-05-14 14:10:41 (GMT) |
commit | bd08a0af2d88c590ede762102bd42da3437e9980 (patch) | |
tree | 9f2e29d7e8c3bfe131fa78a3358afb314ae0f20d /Lib/test/test_robotparser.py | |
parent | 5c0d462689e1a69537eaeba6ab94e3ff3524fc31 (diff) | |
download | cpython-bd08a0af2d88c590ede762102bd42da3437e9980.zip cpython-bd08a0af2d88c590ede762102bd42da3437e9980.tar.gz cpython-bd08a0af2d88c590ede762102bd42da3437e9980.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_robotparser.py')
-rw-r--r-- | Lib/test/test_robotparser.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py index 75198b7..bee8d23 100644 --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -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): |