[Python-checkins] r57626 - in python/trunk/Lib: robotparser.py test/test_robotparser.py

skip.montanaro python-checkins at python.org
Wed Aug 29 01:22:52 CEST 2007


Author: skip.montanaro
Date: Wed Aug 29 01:22:52 2007
New Revision: 57626

Modified:
   python/trunk/Lib/robotparser.py
   python/trunk/Lib/test/test_robotparser.py
Log:
fixes 813986

Modified: python/trunk/Lib/robotparser.py
==============================================================================
--- python/trunk/Lib/robotparser.py	(original)
+++ python/trunk/Lib/robotparser.py	Wed Aug 29 01:22:52 2007
@@ -230,6 +230,11 @@
         urllib.FancyURLopener.__init__(self, *args)
         self.errcode = 200
 
+    def prompt_user_passwd(self, host, realm):
+        ## If robots.txt file is accessible only with a password,
+        ## we act as if the file wasn't there.
+        return None, None
+
     def http_error_default(self, url, fp, errcode, errmsg, headers):
         self.errcode = errcode
         return urllib.FancyURLopener.http_error_default(self, url, fp, errcode,

Modified: python/trunk/Lib/test/test_robotparser.py
==============================================================================
--- python/trunk/Lib/test/test_robotparser.py	(original)
+++ python/trunk/Lib/test/test_robotparser.py	Wed Aug 29 01:22:52 2007
@@ -134,8 +134,19 @@
 
 RobotTest(7, doc, good, bad)
 
+class TestCase(unittest.TestCase):
+    def runTest(self):
+        test_support.requires('network')
+        # whole site is password-protected.
+        url = 'http://mueblesmoraleda.com'
+        parser = robotparser.RobotFileParser()
+        parser.set_url(url)
+        parser.read()
+        self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
+
 def test_main():
     test_support.run_unittest(tests)
+    TestCase().run()
 
 if __name__=='__main__':
     test_support.Verbose = 1


More information about the Python-checkins mailing list