summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_robotparser.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-04-02 17:26:42 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-04-02 17:26:42 (GMT)
commitf37592fda1f3ab3e23d7e3e72faa57f599b9dc9f (patch)
tree8812d91cc122deb2d8933c756740da76682cae8d /Lib/test/test_robotparser.py
parentd54e699cba4abab087bfd625a1fec8b6571ea042 (diff)
downloadcpython-f37592fda1f3ab3e23d7e3e72faa57f599b9dc9f.zip
cpython-f37592fda1f3ab3e23d7e3e72faa57f599b9dc9f.tar.gz
cpython-f37592fda1f3ab3e23d7e3e72faa57f599b9dc9f.tar.bz2
Backport some robotparser test and skip the test if the external resource is not available.
Diffstat (limited to 'Lib/test/test_robotparser.py')
-rw-r--r--Lib/test/test_robotparser.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index 26fb290..405d517 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -203,19 +203,32 @@ RobotTest(13, doc, good, bad, agent="googlebot")
-class TestCase(unittest.TestCase):
- def runTest(self):
+class NetworkTestCase(unittest.TestCase):
+
+ def testPasswordProtectedSite(self):
test_support.requires('network')
- # whole site is password-protected.
+ # XXX it depends on an external resource which could be unavailable
url = 'http://mueblesmoraleda.com'
parser = robotparser.RobotFileParser()
parser.set_url(url)
- parser.read()
+ try:
+ parser.read()
+ except IOError:
+ self.skipTest('%s is unavailable' % url)
self.assertEqual(parser.can_fetch("*", url+"/robots.txt"), False)
+ def testPythonOrg(self):
+ test_support.requires('network')
+ parser = robotparser.RobotFileParser(
+ "http://www.python.org/robots.txt")
+ parser.read()
+ self.assertTrue(parser.can_fetch("*",
+ "http://www.python.org/robots.txt"))
+
+
def test_main():
test_support.run_unittest(tests)
- TestCase().run()
+ test_support.run_unittest(NetworkTestCase)
if __name__=='__main__':
test_support.verbose = 1