From: Senthil Kumaran Date: Sat, 7 Sep 2013 21:09:48 +0000 (-0700) Subject: merge from 3.3 X-Git-Tag: v3.4.0a3~27^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f2ae3903772263ef11d718b9112ae2036112f1b;p=python 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 --- 2f2ae3903772263ef11d718b9112ae2036112f1b diff --cc Lib/site.py index c4ea6f6adb,7e09701415..0bb2ea0081 --- a/Lib/site.py +++ b/Lib/site.py @@@ -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]) diff --cc Lib/test/test_site.py index 4aff932023,2392d43735..34d83f2997 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@@ -402,5 -408,29 +404,27 @@@ class ImportSideEffectTests(unittest.Te 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) + -def test_main(): - run_unittest(HelperFunctionsTests, ImportSideEffectTests, LicenseURL) + if __name__ == "__main__": - test_main() + unittest.main()