Skip to content

Commit 57464b3

Browse files
Use subTest
1 parent eb66a30 commit 57464b3

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

Lib/test/test_urlparse.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,31 +1671,26 @@ def test_to_bytes_deprecation(self):
16711671
self.assertEqual(str(cm.warning),
16721672
'urllib.parse.to_bytes() is deprecated as of 3.8')
16731673

1674-
def test_false_value_deprecation(self):
1674+
def test_falsey_deprecation(self):
16751675
pattern = (
16761676
"Providing false values other than strings or bytes to urllib.parse "
16771677
"is deprecated: got <class "
16781678
)
1679-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1680-
urllib.parse.urljoin('http://www.python.org', [])
1681-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1682-
urllib.parse.urljoin([], b'docs')
1683-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1684-
urllib.parse.urlparse(b'www.python.org', None)
1685-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1686-
urllib.parse.urlparse({}, '')
1687-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1688-
urllib.parse.urlsplit(0, b'http')
1689-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1690-
urllib.parse.urlsplit(b'http://www.python.org', None)
1691-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1692-
urllib.parse.urldefrag(())
1693-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1694-
urllib.parse.urlunparse([None, b'www.python.org', None, None, None, None])
1695-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1696-
urllib.parse.urlunsplit(['http', 0, '', '', ''])
1697-
with self.assertWarnsRegex(DeprecationWarning, pattern):
1698-
urllib.parse.parse_qsl(None, encoding='latin-1')
1679+
cases = [
1680+
(urllib.parse.urljoin, ['http://www.python.org', []]),
1681+
(urllib.parse.urljoin, [[], b'docs']),
1682+
(urllib.parse.urlparse, [b'www.python.org', None]),
1683+
(urllib.parse.urlparse, [{}, '']),
1684+
(urllib.parse.urlsplit, [0, b'http']),
1685+
(urllib.parse.urlsplit, [b'http://www.python.org', None]),
1686+
(urllib.parse.urldefrag, [{}]),
1687+
(urllib.parse.urlunparse, [[None, b'www.python.org', None, None, None, None]]),
1688+
(urllib.parse.urlunsplit, [['http', 0, '', '', '']]),
1689+
]
1690+
for callable, args in cases:
1691+
with self.subTest(callable=callable):
1692+
with self.assertWarnsRegex(DeprecationWarning, pattern):
1693+
callable(*args)
16991694

17001695

17011696
if __name__ == "__main__":

0 commit comments

Comments
 (0)