summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_site.py
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2013-09-09 12:12:21 (GMT)
committerLarry Hastings <larry@hastings.org>2013-09-09 12:12:21 (GMT)
commit8568f66daf088cf235a42288621fb4770ac48199 (patch)
tree3db459417e7c4b112b03d59661057f09ff058d07 /Lib/test/test_site.py
parent60560b18d29a917e64d88d47c5533743001f0787 (diff)
parent23543ebd8676384c1c5e28f7a1496777a57479d5 (diff)
downloadcpython-8568f66daf088cf235a42288621fb4770ac48199.zip
cpython-8568f66daf088cf235a42288621fb4770ac48199.tar.gz
cpython-8568f66daf088cf235a42288621fb4770ac48199.tar.bz2
Merge.
Diffstat (limited to 'Lib/test/test_site.py')
-rw-r--r--Lib/test/test_site.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 4aff932..34d83f2 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -5,6 +5,7 @@ executing have not been removed.
"""
import unittest
+import test.support
from test.support import run_unittest, TESTFN, EnvironmentVarGuard
from test.support import captured_stderr
import builtins
@@ -373,9 +374,10 @@ class ImportSideEffectTests(unittest.TestCase):
self.assertTrue(hasattr(builtins, "exit"))
def test_setting_copyright(self):
- # 'copyright' and 'credits' should be in builtins
+ # 'copyright', 'credits', and 'license' should be in builtins
self.assertTrue(hasattr(builtins, "copyright"))
self.assertTrue(hasattr(builtins, "credits"))
+ self.assertTrue(hasattr(builtins, "license"))
def test_setting_help(self):
# 'help' should be set in builtins
@@ -402,5 +404,27 @@ class ImportSideEffectTests(unittest.TestCase):
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)
+ 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)
+
+
if __name__ == "__main__":
unittest.main()