diff options
Diffstat (limited to 'Lib/test/test_robotparser.py')
-rw-r--r-- | Lib/test/test_robotparser.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py index 178761dd38..ebc819c4f8 100644 --- a/Lib/test/test_robotparser.py +++ b/Lib/test/test_robotparser.py @@ -6,7 +6,10 @@ from urllib.request import urlopen from test import support class RobotTestCase(unittest.TestCase): - def __init__(self, index, parser, url, good, agent): + def __init__(self, index=None, parser=None, url=None, good=None, agent=None): + # workaround to make unittest discovery work (see #17066) + if not isinstance(index, int): + return unittest.TestCase.__init__(self) if good: self.str = "RobotTest(%d, good, %s)" % (index, url) @@ -231,6 +234,18 @@ bad = ['/some/path'] RobotTest(15, doc, good, bad) +# 16. Empty query (issue #17403). Normalizing the url first. +doc = """ +User-agent: * +Allow: /some/path? +Disallow: /another/path? +""" + +good = ['/some/path?'] +bad = ['/another/path?'] + +RobotTest(16, doc, good, bad) + class NetworkTestCase(unittest.TestCase): @@ -260,6 +275,7 @@ class NetworkTestCase(unittest.TestCase): self.skipTest('%s is unavailable' % url) self.assertEqual(parser.can_fetch("*", robots_url), False) + @unittest.skip('does not handle the gzip encoding delivered by pydotorg') def testPythonOrg(self): support.requires('network') with support.transient_internet('www.python.org'): @@ -269,10 +285,11 @@ class NetworkTestCase(unittest.TestCase): self.assertTrue( parser.can_fetch("*", "http://www.python.org/robots.txt")) -def test_main(): - support.run_unittest(NetworkTestCase) - support.run_unittest(tests) +def load_tests(loader, suite, pattern): + suite = unittest.makeSuite(NetworkTestCase) + suite.addTest(tests) + return suite if __name__=='__main__': - support.verbose = 1 - test_main() + support.use_resources = ['network'] + unittest.main() |