|
2 | 2 | from test import test_support |
3 | 3 | from urllib2 import urlopen, HTTPError |
4 | 4 |
|
| 5 | +HAVE_HTTPS = True |
| 6 | +try: |
| 7 | + from urllib2 import HTTPSHandler |
| 8 | +except ImportError: |
| 9 | + HAVE_HTTPS = False |
| 10 | + |
5 | 11 | class RobotTestCase(unittest.TestCase): |
6 | 12 | def __init__(self, index, parser, url, good, agent): |
7 | 13 | unittest.TestCase.__init__(self) |
@@ -228,6 +234,18 @@ def RobotTest(index, robots_txt, good_urls, bad_urls, |
228 | 234 |
|
229 | 235 | RobotTest(15, doc, good, bad) |
230 | 236 |
|
| 237 | +# 16. Empty query (issue #17403). Normalizing the url first. |
| 238 | +doc = """ |
| 239 | +User-agent: * |
| 240 | +Allow: /some/path? |
| 241 | +Disallow: /another/path? |
| 242 | +""" |
| 243 | + |
| 244 | +good = ['/some/path?'] |
| 245 | +bad = ['/another/path?'] |
| 246 | + |
| 247 | +RobotTest(16, doc, good, bad) |
| 248 | + |
231 | 249 |
|
232 | 250 | class NetworkTestCase(unittest.TestCase): |
233 | 251 |
|
@@ -257,14 +275,16 @@ def testPasswordProtectedSite(self): |
257 | 275 | self.skipTest('%s is unavailable' % url) |
258 | 276 | self.assertEqual(parser.can_fetch("*", robots_url), False) |
259 | 277 |
|
| 278 | + @unittest.skipUnless(HAVE_HTTPS, 'need SSL support to download license') |
| 279 | + @test_support.system_must_validate_cert |
260 | 280 | def testPythonOrg(self): |
261 | 281 | test_support.requires('network') |
262 | 282 | with test_support.transient_internet('www.python.org'): |
263 | 283 | parser = robotparser.RobotFileParser( |
264 | | - "http://www.python.org/robots.txt") |
| 284 | + "https://www.python.org/robots.txt") |
265 | 285 | parser.read() |
266 | 286 | self.assertTrue( |
267 | | - parser.can_fetch("*", "http://www.python.org/robots.txt")) |
| 287 | + parser.can_fetch("*", "https://www.python.org/robots.txt")) |
268 | 288 |
|
269 | 289 |
|
270 | 290 | def test_main(): |
|
0 commit comments