]> granicus.if.org Git - python/commitdiff
merge from 3.3
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 7 Sep 2013 21:09:48 +0000 (14:09 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Sat, 7 Sep 2013 21:09:48 +0000 (14:09 -0700)
Fix License URL display and add test to check for license url presence.
Fixes issue #18206 Patch contributed by  Berker Peksag and py.user

1  2 
Lib/site.py
Lib/test/test_site.py

diff --cc Lib/site.py
index c4ea6f6adb9732afc31f6df749ffd3ba502c0e39,7e097014155b4fbd0e9f73b5ddfeb3fa6b784612..0bb2ea0081ed716d7ea7cb21e27a5abaea28775f
@@@ -361,8 -450,9 +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])
  
index 4aff9320238852e6190f5589e4679fac41d12c56,2392d43735930d2aa82b1eecd1dec973e049a47f..34d83f29970c1c572968e4ceb51a227b4b4f31c3
@@@ -402,5 -408,29 +404,27 @@@ class ImportSideEffectTests(unittest.Te
                  self.fail("sitecustomize not imported automatically")
  
  
 -def test_main():
 -    run_unittest(HelperFunctionsTests, ImportSideEffectTests, LicenseURL)
+ 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__":
 -    test_main()
 +    unittest.main()