-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete removal of
SplitResult
as an internal (#1396)
- Loading branch information
Showing
6 changed files
with
95 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Improved performance many :class:`~yarl.URL` methods -- by :user:`bdraco`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,13 +132,13 @@ def test_scheme(): | |
def test_raw_user(): | ||
url = URL("http://[email protected]") | ||
assert "user" == url.raw_user | ||
assert url.raw_user == url._val.username | ||
assert url.raw_user == SplitResult(*url._val).username | ||
|
||
|
||
def test_raw_user_non_ascii(): | ||
url = URL("http://бажан@example.com") | ||
assert "%D0%B1%D0%B0%D0%B6%D0%B0%D0%BD" == url.raw_user | ||
assert url.raw_user == url._val.username | ||
assert url.raw_user == SplitResult(*url._val).username | ||
|
||
|
||
def test_no_user(): | ||
|
@@ -154,13 +154,13 @@ def test_user_non_ascii(): | |
def test_raw_password(): | ||
url = URL("http://user:[email protected]") | ||
assert "password" == url.raw_password | ||
assert url.raw_password == url._val.password | ||
assert url.raw_password == SplitResult(*url._val).password | ||
|
||
|
||
def test_raw_password_non_ascii(): | ||
url = URL("http://user:пароль@example.com") | ||
assert "%D0%BF%D0%B0%D1%80%D0%BE%D0%BB%D1%8C" == url.raw_password | ||
assert url.raw_password == url._val.password | ||
assert url.raw_password == SplitResult(*url._val).password | ||
|
||
|
||
def test_password_non_ascii(): | ||
|
@@ -179,7 +179,7 @@ def test_empty_password_without_user(): | |
assert url.user is None | ||
assert url.password == "" | ||
assert url.raw_password == "" | ||
assert url.raw_password == url._val.password | ||
assert url.raw_password == SplitResult(*url._val).password | ||
|
||
|
||
def test_user_empty_password(): | ||
|
@@ -191,7 +191,7 @@ def test_user_empty_password(): | |
def test_raw_host(): | ||
url = URL("http://example.com") | ||
assert "example.com" == url.raw_host | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
@pytest.mark.parametrize( | ||
|
@@ -244,7 +244,7 @@ def test_invalid_idna_a_label_encoding(): | |
def test_raw_host_non_ascii(): | ||
url = URL("http://оун-упа.укр") | ||
assert "xn----8sb1bdhvc.xn--j1amh" == url.raw_host | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_host_non_ascii(): | ||
|
@@ -265,19 +265,19 @@ def test_host_with_underscore(): | |
def test_raw_host_when_port_is_specified(): | ||
url = URL("http://example.com:8888") | ||
assert "example.com" == url.raw_host | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_raw_host_from_str_with_ipv4(): | ||
url = URL("http://127.0.0.1:80") | ||
assert url.raw_host == "127.0.0.1" | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_raw_host_from_str_with_ipv6(): | ||
url = URL("http://[::1]:80") | ||
assert url.raw_host == "::1" | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_authority_full() -> None: | ||
|
@@ -311,21 +311,21 @@ def test_lowercase(): | |
url = URL("http://gitHUB.com") | ||
assert url.raw_host == "github.com" | ||
assert url.host == url.raw_host | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_lowercase_nonascii(): | ||
url = URL("http://Слава.Укр") | ||
assert url.raw_host == "xn--80aaf8a3a.xn--j1amh" | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
assert url.host == "слава.укр" | ||
|
||
|
||
def test_compressed_ipv6(): | ||
url = URL("http://[1DEC:0:0:0::1]") | ||
assert url.raw_host == "1dec::1" | ||
assert url.host == url.raw_host | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_ipv6_missing_left_bracket(): | ||
|
@@ -353,19 +353,19 @@ def test_ipv4_zone(): | |
url = URL("http://1.2.3.4%тест%42:123") | ||
assert url.raw_host == "1.2.3.4%тест%42" | ||
assert url.host == url.raw_host | ||
assert url.raw_host == url._val.hostname | ||
assert url.raw_host == SplitResult(*url._val).hostname | ||
|
||
|
||
def test_port_for_explicit_port(): | ||
url = URL("http://example.com:8888") | ||
assert 8888 == url.port | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
|
||
|
||
def test_port_for_implicit_port(): | ||
url = URL("http://example.com") | ||
assert 80 == url.port | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
|
||
|
||
def test_port_for_relative_url(): | ||
|
@@ -383,25 +383,25 @@ def test_port_for_unknown_scheme(): | |
def test_explicit_port_for_explicit_port(): | ||
url = URL("http://example.com:8888") | ||
assert 8888 == url.explicit_port | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
|
||
|
||
def test_explicit_port_for_implicit_port(): | ||
url = URL("http://example.com") | ||
assert url.explicit_port is None | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
|
||
|
||
def test_explicit_port_for_relative_url(): | ||
url = URL("/path/to") | ||
assert url.explicit_port is None | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
|
||
|
||
def test_explicit_port_for_unknown_scheme(): | ||
url = URL("unknown://example.com") | ||
assert url.explicit_port is None | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
|
||
|
||
def test_raw_path_string_empty(): | ||
|
@@ -1563,7 +1563,7 @@ def test_is_default_port_for_unknown_scheme(): | |
def test_handling_port_zero(): | ||
url = URL("http://example.com:0") | ||
assert url.explicit_port == 0 | ||
assert url.explicit_port == url._val.port | ||
assert url.explicit_port == SplitResult(*url._val).port | ||
assert str(url) == "http://example.com:0" | ||
assert not url.is_default_port() | ||
|
||
|
@@ -1767,13 +1767,13 @@ def test_parent_for_empty_url(): | |
def test_parent_for_relative_url_with_child(): | ||
url = URL("path/to") | ||
assert url.parent == URL("path") | ||
assert url.parent._val.path == "path" | ||
assert SplitResult(*url.parent._val).path == "path" | ||
|
||
|
||
def test_parent_for_relative_url(): | ||
url = URL("path") | ||
assert url.parent == URL("") | ||
assert url.parent._val.path == "" | ||
assert SplitResult(*url.parent._val).path == "" | ||
|
||
|
||
def test_parent_for_no_netloc_url(): | ||
|
@@ -1784,7 +1784,7 @@ def test_parent_for_no_netloc_url(): | |
def test_parent_for_top_level_no_netloc_url(): | ||
url = URL("/") | ||
assert url.parent == URL("/") | ||
assert url.parent._val.path == "/" | ||
assert SplitResult(*url.parent._val).path == "/" | ||
|
||
|
||
def test_parent_for_absolute_url(): | ||
|
@@ -1795,7 +1795,7 @@ def test_parent_for_absolute_url(): | |
def test_parent_for_top_level_absolute_url(): | ||
url = URL("http://go.to/") | ||
assert url.parent == URL("http://go.to/") | ||
assert url.parent._val.path == "/" | ||
assert SplitResult(*url.parent._val).path == "/" | ||
|
||
|
||
def test_empty_value_for_query(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.