From: Yeray Diaz Diaz Date: Wed, 15 May 2019 13:30:00 +0000 (+0100) Subject: Include URL.__hash__ in test (#64) X-Git-Tag: 0.3.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e9ab2e904abe5feec2ccb74eecb7f874bde5ba9;p=thirdparty%2Fhttpx.git Include URL.__hash__ in test (#64) * 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 --- diff --git a/httpcore/models.py b/httpcore/models.py index 946ae166..68ab4b2d 100644 --- a/httpcore/models.py +++ b/httpcore/models.py @@ -4,10 +4,8 @@ import typing from urllib.parse import parse_qsl, urlencode import chardet -import idna import rfc3986 -from .config import SSLConfig, TimeoutConfig from .decoders import ( ACCEPT_ENCODING, SUPPORTED_DECODERS, @@ -808,7 +806,7 @@ class SyncResponse: while True: try: yield self._loop.run_until_complete(inner.__anext__()) - except StopAsyncIteration as exc: + except StopAsyncIteration: break def raw(self) -> typing.Iterator[bytes]: @@ -816,7 +814,7 @@ class SyncResponse: while True: try: yield self._loop.run_until_complete(inner.__anext__()) - except StopAsyncIteration as exc: + except StopAsyncIteration: break def close(self) -> None: diff --git a/tests/models/test_requests.py b/tests/models/test_requests.py index f010db8c..c7faf816 100644 --- a/tests/models/test_requests.py +++ b/tests/models/test_requests.py @@ -98,12 +98,14 @@ def test_override_content_length_header(): def test_url(): - request = httpcore.Request("GET", "http://example.org") + url = "http://example.org" + request = httpcore.Request("GET", url) assert request.url.scheme == "http" assert request.url.port == 80 assert request.url.full_path == "/" - request = httpcore.Request("GET", "https://example.org/abc?foo=bar") + url = "https://example.org/abc?foo=bar" + request = httpcore.Request("GET", url) assert request.url.scheme == "https" assert request.url.port == 443 assert request.url.full_path == "/abc?foo=bar" diff --git a/tests/models/test_url.py b/tests/models/test_url.py index 9ed96f6d..98e01d9d 100644 --- a/tests/models/test_url.py +++ b/tests/models/test_url.py @@ -33,3 +33,14 @@ def test_url_query_params(): "https://example.org:123/path/to/somewhere?b=456", query_params={"a": "123"} ) assert str(url) == "https://example.org:123/path/to/somewhere?a=123" + + +def test_url_set(): + urls = ( + URL("http://example.org:123/path/to/somewhere"), + URL("http://example.org:123/path/to/somewhere/else"), + ) + + url_set = set(urls) + + assert all(url in urls for url in url_set)