(self)
| 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/", |
nothing calls this directly
no test coverage detected