summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_robotparser.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-05-14 22:09:47 (GMT)
committerGitHub <noreply@github.com>2018-05-14 22:09:47 (GMT)
commit861d38443d4b85cdc7b87afc4adee55f51c2f4b3 (patch)
tree9e702bbf51583e4740b44af2a1d113ba007d811d /Lib/test/test_robotparser.py
parent84fc6c59cf286fc4e6b3a700c6db36ecc2bff92b (diff)
downloadcpython-861d38443d4b85cdc7b87afc4adee55f51c2f4b3.zip
cpython-861d38443d4b85cdc7b87afc4adee55f51c2f4b3.tar.gz
cpython-861d38443d4b85cdc7b87afc4adee55f51c2f4b3.tar.bz2
[2.7] bpo-32861: robotparser fix incomplete __str__ methods. (GH-5711) (GH-6795) (GH-6817)
The robotparser's __str__ representation now includes wildcard entries. (cherry picked from commit c3fa1f2b93fa4bf96a8aadc74ee196384cefa31e) Co-authored-by: Michael Lazar <lazar.michael22@gmail.com>.
Diffstat (limited to 'Lib/test/test_robotparser.py')
-rw-r--r--Lib/test/test_robotparser.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index 8ed5d89..ba7ccf8 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -136,6 +136,31 @@ 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: *
+Disallow: /cyberworld/map/
+
+"""
+
+ def test_string_formatting(self):
+ self.assertEqual(str(self.parser), self.expected_output)
+
+
class RobotHandler(BaseHTTPRequestHandler):
def do_GET(self):
@@ -226,6 +251,7 @@ def test_main():
UseFirstUserAgentWildcardTest,
EmptyQueryStringTest,
DefaultEntryTest,
+ StringFormattingTest,
PasswordProtectedSiteTestCase,
NetworkTestCase)