MCPcopy Index your code
hub / github.com/python/cpython / test_license_exists_at_url

Method test_license_exists_at_url

Lib/test/test_site.py:552–565  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

550 @test.support.requires_resource('network')
551 @test.support.system_must_validate_cert
552 def test_license_exists_at_url(self):
553 # This test is a bit fragile since it depends on the format of the
554 # string displayed by license in the absence of a LICENSE file.
555 url = license._Printer__data.split()[1]
556 req = urllib.request.Request(url, method='HEAD')
557 # Reset global urllib.request._opener
558 self.addCleanup(urllib.request.urlcleanup)
559 try:
560 with socket_helper.transient_internet(url):
561 with urllib.request.urlopen(req) as data:
562 code = data.getcode()
563 except urllib.error.HTTPError as e:
564 code = e.code
565 self.assertEqual(code, 200, msg="Can't find " + url)
566
567 @support.cpython_only
568 def test_lazy_imports(self):

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
splitMethod · 0.45
urlopenMethod · 0.45
getcodeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected