Skip to content

Commit c68331d

Browse files
committed
test_url.py: UNSET → None
1 parent 4b4ba4a commit c68331d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tests/test_url.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import unittest
3-
from typing import Any, Union, Type, Callable, cast, Tuple, List
3+
from typing import Any, Optional, Union, Type, Callable, cast, Tuple, List
44
from urllib.parse import urlparse
55

66
import pytest
@@ -29,17 +29,16 @@
2929
url_query_cleaner,
3030
)
3131

32-
33-
UNSET = object()
34-
3532
# Test cases for URL-to-safe-URL conversions with a URL and an encoding as
3633
# input parameters.
3734
#
3835
# (encoding, input URL, output URL or exception)
39-
SAFE_URL_ENCODING_CASES: List[Tuple[Any, StrOrBytes, Union[str, Type[Exception]]]] = [
40-
(UNSET, "", ValueError),
41-
(UNSET, "https://example.com", "https://example.com"),
42-
(UNSET, "https://example.com/©", "https://example.com/%C2%A9"),
36+
SAFE_URL_ENCODING_CASES: List[
37+
Tuple[Optional[str], StrOrBytes, Union[str, Type[Exception]]]
38+
] = [
39+
(None, "", ValueError),
40+
(None, "https://example.com", "https://example.com"),
41+
(None, "https://example.com/©", "https://example.com/%C2%A9"),
4342
# Paths are always UTF-8-encoded.
4443
("iso-8859-1", "https://example.com/©", "https://example.com/%C2%A9"),
4544
# Queries are UTF-8-encoded if the scheme is not special, ws or wss.
@@ -317,17 +316,15 @@
317316
)
318317

319318

320-
# encoding is actually either str or literally UNSET, but typing.Literal
321-
# doesn't support literals of arbitrary types
322319
def _test_safe_url_func(
323320
url: StrOrBytes,
324321
*,
325-
encoding: Any = UNSET,
322+
encoding: Optional[str] = None,
326323
output: Union[str, Type[Exception]],
327324
func: Callable[..., str],
328325
) -> None:
329326
kwargs = {}
330-
if encoding is not UNSET:
327+
if encoding is not None:
331328
kwargs["encoding"] = encoding
332329
try:
333330
is_exception = issubclass(cast(Type[Exception], output), Exception)
@@ -343,7 +340,10 @@ def _test_safe_url_func(
343340

344341

345342
def _test_safe_url_string(
346-
url: StrOrBytes, *, encoding: Any = UNSET, output: Union[str, Type[Exception]]
343+
url: StrOrBytes,
344+
*,
345+
encoding: Optional[str] = None,
346+
output: Union[str, Type[Exception]],
347347
) -> None:
348348
return _test_safe_url_func(
349349
url,
@@ -354,7 +354,7 @@ def _test_safe_url_string(
354354

355355

356356
KNOWN_SAFE_URL_STRING_ENCODING_ISSUES = {
357-
(UNSET, ""), # Invalid URL
357+
(None, ""), # Invalid URL
358358
# UTF-8 encoding is not enforced in non-special URLs, or in URLs with the
359359
# ws or wss schemas.
360360
("iso-8859-1", "a://example.com?\xa9"),

0 commit comments

Comments
 (0)