Skip to content

Commit 93ce994

Browse files
committed
try: issubclass → isclass and issubclass
1 parent c68331d commit 93ce994

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/test_url.py

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

@@ -326,12 +327,8 @@ def _test_safe_url_func(
326327
kwargs = {}
327328
if encoding is not None:
328329
kwargs["encoding"] = encoding
329-
try:
330-
is_exception = issubclass(cast(Type[Exception], output), Exception)
331-
except TypeError:
332-
is_exception = False
333-
if is_exception:
334-
with pytest.raises(cast(Type[Exception], output)):
330+
if isclass(output) and issubclass(output, Exception):
331+
with pytest.raises(output):
335332
func(url, **kwargs)
336333
return
337334
actual = func(url, **kwargs)

0 commit comments

Comments
 (0)