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

Method test_empty_path

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

Source from the content-addressed store, hash-verified

1951 self.assertEqual(len(c), 2)
1952
1953 def test_empty_path(self):
1954 # Test for empty path
1955 # Broken web-server ORION/1.3.38 returns to the client response like
1956 #
1957 # Set-Cookie: JSESSIONID=ABCDERANDOM123; Path=
1958 #
1959 # ie. with Path set to nothing.
1960 # In this case, extract_cookies() must set cookie to / (root)
1961 c = CookieJar(DefaultCookiePolicy(rfc2965 = True))
1962 headers = []
1963
1964 req = urllib.request.Request("http://www.ants.com/")
1965 headers.append("Set-Cookie: JSESSIONID=ABCDERANDOM123; Path=")
1966 res = FakeResponse(headers, "http://www.ants.com/")
1967 c.extract_cookies(res, req)
1968
1969 req = urllib.request.Request("http://www.ants.com/")
1970 c.add_cookie_header(req)
1971
1972 self.assertEqual(req.get_header("Cookie"),
1973 "JSESSIONID=ABCDERANDOM123")
1974 self.assertEqual(req.get_header("Cookie2"), '$Version="1"')
1975
1976 # missing path in the request URI
1977 req = urllib.request.Request("http://www.ants.com:8080")
1978 c.add_cookie_header(req)
1979
1980 self.assertEqual(req.get_header("Cookie"),
1981 "JSESSIONID=ABCDERANDOM123")
1982 self.assertEqual(req.get_header("Cookie2"), '$Version="1"')
1983
1984 def test_session_cookies(self):
1985 year_plus_one = time.localtime()[0] + 1

Callers

nothing calls this directly

Calls 8

extract_cookiesMethod · 0.95
add_cookie_headerMethod · 0.95
get_headerMethod · 0.95
CookieJarClass · 0.90
DefaultCookiePolicyClass · 0.90
FakeResponseClass · 0.85
appendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected