Skip to content
Myr

Add repr to Cookies for displaying available cookies (#1411)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Add repr to Cookies for displaying available cookies * Add unit test * Simplify repr * Remove file

authored by Andrés Álvarez · committed by GitHub · parent 9005bd5 · Browse files · 2 files+21 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+21 added−0 removed

  • tests:+11 added−0 removed
  • other:+10 added−0 removed

2 files+21 added−0 removed

modified:httpx/_models.py+10 added
1489 unmodified lines
1490 for _ in self.jar:1491 return True1492 return False14931494 def __repr__(self) -> str:1495 cookies_repr = ", ".join(1496 [1497 f"<Cookie {cookie.name}={cookie.value} for {cookie.domain} />"1498 for cookie in self.jar1499 ]1500 )15011502 return f"<Cookies[{cookies_repr}]>"15031504 class _CookieCompatRequest(urllib.request.Request):1505 """1506 Wraps a `Request` instance up in a compatibility interface suitable1507 for use with `CookieJar` operations.
31 unmodified lines
modified:tests/models/test_cookies.py+11 added
83 unmodified lines
8485 assert len(cookies.items()) == 286 for k, v in cookies_val:87 assert cookies[k] == v888990def test_cookies_repr():91 cookies = httpx.Cookies()92 cookies.set(name="foo", value="bar", domain="http://blah.com")93 cookies.set(name="fizz", value="buzz", domain="http://hello.com")9495 assert (96 repr(cookies)97 == "<Cookies[<Cookie foo=bar for http://blah.com />, <Cookie fizz=buzz for http://hello.com />]>"98 )