Skip to content
Myr

Include URL.__hash__ in test (#64)

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

* Include URL.__hash__ in test * Add test for URLs being used in a set Remove hash assertion on test requests * Cleanup models.py * Use membership test instead of equality to avoid ordering problems

authored by Yeray Diaz Diaz · committed by Tom Christie · parent 019c5d1 · Browse files · 3 files+17 added−6 removed
This commit

State

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

Diff stats

3 files+17 added−6 removed

  • tests:+15 added−2 removed
  • other:+2 added−4 removed

3 files+17 added−6 removed

modified:httpcore/models.py+2 added-4 removed
2 unmodified lines
3import typing4from urllib.parse import parse_qsl, urlencode56import chardet7import idna7import rfc3986810from .config import SSLConfig, TimeoutConfig9from .decoders import (10 ACCEPT_ENCODING,11 SUPPORTED_DECODERS,12 Decoder,
792 unmodified lines
805 inner = self._response.stream()806 while True:807 try:808 yield self._loop.run_until_complete(inner.__anext__())811 except StopAsyncIteration as exc:809 except StopAsyncIteration:810 break811812 def raw(self) -> typing.Iterator[bytes]:813 inner = self._response.raw()814 while True:815 try:816 yield self._loop.run_until_complete(inner.__anext__())819 except StopAsyncIteration as exc:817 except StopAsyncIteration:818 break819820 def close(self) -> None:821 return self._loop.run_until_complete(self._response.close())
3 unmodified lines
modified:tests/models/test_requests.py+4 added-2 removed
96 unmodified lines
97 )9899100def test_url():101 url = "http://example.org"101 request = httpcore.Request("GET", "http://example.org")102 request = httpcore.Request("GET", url)103 assert request.url.scheme == "http"104 assert request.url.port == 80105 assert request.url.full_path == "/"106106 request = httpcore.Request("GET", "https://example.org/abc?foo=bar")107 url = "https://example.org/abc?foo=bar"108 request = httpcore.Request("GET", url)109 assert request.url.scheme == "https"110 assert request.url.port == 443111 assert request.url.full_path == "/abc?foo=bar"112
10 unmodified lines
modified:tests/models/test_url.py+11 added
31 unmodified lines
32 url = URL(33 "https://example.org:123/path/to/somewhere?b=456", query_params={"a": "123"}34 )35 assert str(url) == "https://example.org:123/path/to/somewhere?a=123"363738def test_url_set():39 urls = (40 URL("http://example.org:123/path/to/somewhere"),41 URL("http://example.org:123/path/to/somewhere/else"),42 )4344 url_set = set(urls)4546 assert all(url in urls for url in url_set)