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

Method test_path_prefix_match

Lib/test/test_http_cookiejar.py:811–833  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

809 self.assertEqual(request_path(req), "/")
810
811 def test_path_prefix_match(self):
812 pol = DefaultCookiePolicy()
813 strict_ns_path_pol = DefaultCookiePolicy(strict_ns_set_path=True)
814
815 c = CookieJar(pol)
816 base_url = "http://bar.com"
817 interact_netscape(c, base_url, 'spam=eggs; Path=/foo')
818 cookie = c._cookies['bar.com']['/foo']['spam']
819
820 for path, ok in [('/foo', True),
821 ('/foo/', True),
822 ('/foo/bar', True),
823 ('/', False),
824 ('/foobad/foo', False)]:
825 url = f'{base_url}{path}'
826 req = urllib.request.Request(url)
827 h = interact_netscape(c, url)
828 if ok:
829 self.assertIn('spam=eggs', h, f"cookie not set for {path}")
830 self.assertTrue(strict_ns_path_pol.set_ok_path(cookie, req))
831 else:
832 self.assertNotIn('spam=eggs', h, f"cookie set for {path}")
833 self.assertFalse(strict_ns_path_pol.set_ok_path(cookie, req))
834
835 def test_request_port(self):
836 req = urllib.request.Request("http://www.acme.com:1234/",

Callers

nothing calls this directly

Calls 8

set_ok_pathMethod · 0.95
DefaultCookiePolicyClass · 0.90
CookieJarClass · 0.90
interact_netscapeFunction · 0.85
assertInMethod · 0.80
assertTrueMethod · 0.80
assertNotInMethod · 0.80
assertFalseMethod · 0.80

Tested by

no test coverage detected