summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-09-07 21:09:48 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-09-07 21:09:48 (GMT)
commit2f2ae3903772263ef11d718b9112ae2036112f1b (patch)
treea35f5e8371911fb47974876ac91701a8b24b7722 /Lib
parent59b74ec5e363ce0cd5640c16ccb58d18bf0aee99 (diff)
parent8ef519b24f61d6e4307a4886920482c30f93aa7a (diff)
downloadcpython-2f2ae3903772263ef11d718b9112ae2036112f1b.zip
cpython-2f2ae3903772263ef11d718b9112ae2036112f1b.tar.gz
cpython-2f2ae3903772263ef11d718b9112ae2036112f1b.tar.bz2
merge from 3.3
Fix License URL display and add test to check for license url presence. Fixes issue #18206 Patch contributed by Berker Peksag and py.user
Diffstat (limited to 'Lib')
-rw-r--r--Lib/site.py6
-rw-r--r--Lib/test/test_site.py26
2 files changed, 31 insertions, 1 deletions
diff --git a/Lib/site.py b/Lib/site.py
index c4ea6f6..0bb2ea0 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -361,8 +361,14 @@ def setcopyright():
Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information.""")
here = os.path.dirname(os.__file__)
+<<<<<<< local
builtins.license = _sitebuiltins._Printer(
"license", "See http://www.python.org/%.3s/license.html" % sys.version,
+=======
+ builtins.license = _Printer(
+ "license",
+ "See http://www.python.org/download/releases/%.5s/license/" % sys.version,
+>>>>>>> other
["LICENSE.txt", "LICENSE"],
[os.path.join(here, os.pardir), here, os.curdir])
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()