summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-09-14 17:31:14 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-09-14 17:31:14 (GMT)
commitf11caa0bba648d744c1d4050b11038505fd6e1fe (patch)
tree90635e35856f0f72b27298ca4c66d481b3494713
parentc79413df5efc3e4e46135ff0ca0ddb601a2313c2 (diff)
parent1bc6ceba923e41a85d529aefbc0bbb8c1dd4bd10 (diff)
downloadcpython-f11caa0bba648d744c1d4050b11038505fd6e1fe.zip
cpython-f11caa0bba648d744c1d4050b11038505fd6e1fe.tar.gz
cpython-f11caa0bba648d744c1d4050b11038505fd6e1fe.tar.bz2
Merge #18206: Fix test for existence of license URL.
This test will fail because a previous attempt to fix a merge error in site.py was incorrect, but the test wasn't running so it wasn't caught. The next commit will fix the site.py bug.
-rw-r--r--Lib/test/test_site.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 34d83f2..575d65b 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -13,6 +13,8 @@ import os
import sys
import re
import encodings
+import urllib.request
+import urllib.error
import subprocess
import sysconfig
from copy import copy
@@ -403,27 +405,19 @@ class ImportSideEffectTests(unittest.TestCase):
else:
self.fail("sitecustomize not imported automatically")
-
-class LicenseURL(unittest.TestCase):
- """Test accessibility of the license."""
-
- @unittest.skipUnless(str(license).startswith('See http://'),
- 'license is available as a file')
- def test_license_page(self):
- """urlopen should return the license page"""
- pat = r'^See (http://www\.python\.org/download/releases/[^/]+/license/)$'
- mo = re.search(pat, str(license))
- self.assertIsNotNone(mo, msg='can\'t find appropriate url in license')
- if mo is not None:
- url = mo.group(1)
+ @test.support.requires_resource('network')
+ def test_license_exists_at_url(self):
+ # This test is a bit fragile since it depends on the format of the
+ # string displayed by license in the absence of a LICENSE file.
+ url = license._Printer__data.split()[1]
+ req = urllib.request.Request(url, method='HEAD')
+ try:
with test.support.transient_internet(url):
- import urllib.request, urllib.error
- try:
- with urllib.request.urlopen(url) as data:
- code = data.getcode()
- except urllib.error.HTTPError as e:
- code = e.code
- self.assertEqual(code, 200, msg=url)
+ with urllib.request.urlopen(req) as data:
+ code = data.getcode()
+ except urllib.error.HTTPError as e:
+ code = e.code
+ self.assertEqual(code, 200, msg="Can't find " + url)
if __name__ == "__main__":