Back to index

python3.2  3.2.2
Public Member Functions
test.test_robotparser.NetworkTestCase Class Reference

List of all members.

Public Member Functions

def testPasswordProtectedSite
def testPythonOrg

Detailed Description

Definition at line 235 of file test_robotparser.py.


Member Function Documentation

Definition at line 237 of file test_robotparser.py.

00237 
00238     def testPasswordProtectedSite(self):
00239         support.requires('network')
00240         with support.transient_internet('mueblesmoraleda.com'):
00241             url = 'http://mueblesmoraleda.com'
00242             robots_url = url + "/robots.txt"
00243             # First check the URL is usable for our purposes, since the
00244             # test site is a bit flaky.
00245             try:
00246                 urlopen(robots_url)
00247             except HTTPError as e:
00248                 if e.code not in {401, 403}:
00249                     self.skipTest(
00250                         "%r should return a 401 or 403 HTTP error, not %r"
00251                         % (robots_url, e.code))
00252             else:
00253                 self.skipTest(
00254                     "%r should return a 401 or 403 HTTP error, not succeed"
00255                     % (robots_url))
00256             parser = urllib.robotparser.RobotFileParser()
00257             parser.set_url(url)
00258             try:
00259                 parser.read()
00260             except URLError:
00261                 self.skipTest('%s is unavailable' % url)
00262             self.assertEqual(parser.can_fetch("*", robots_url), False)

Here is the call graph for this function:

Definition at line 263 of file test_robotparser.py.

00263 
00264     def testPythonOrg(self):
00265         support.requires('network')
00266         with support.transient_internet('www.python.org'):
00267             parser = urllib.robotparser.RobotFileParser(
00268                 "http://www.python.org/robots.txt")
00269             parser.read()
00270             self.assertTrue(
00271                 parser.can_fetch("*", "http://www.python.org/robots.txt"))

Here is the call graph for this function:


The documentation for this class was generated from the following file: