Skip to content

Commit 7f06c22

Browse files
Do not check two deprecation warnings with assertWarnsRegex()
It re-emits the warnings which do not match, so the warning for the other parameter was raised as an error.
1 parent fd31f65 commit 7f06c22

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Lib/test/test_clinic.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import re
1616
import sys
1717
import unittest
18+
import warnings
1819

1920
test_tools.skip_if_missing('clinic')
2021
with test_tools.imports_under_tool('clinic'):
@@ -4748,8 +4749,15 @@ def errmsg(name):
47484749
f"is deprecated. "
47494750
f"It will be removed in Python 3.14.")
47504751
self.check_depr(errmsg('b'), fn, 1, 2)
4751-
self.check_depr(errmsg('c'), fn, 1, 2, 3)
47524752
self.check_depr(errmsg('d'), fn, 1, d=4)
4753+
# Each deprecated parameter is reported on its own.
4754+
with warnings.catch_warnings(record=True) as caught:
4755+
warnings.simplefilter("always")
4756+
self.assertEqual(fn(1, 2, 3), (1, 2, 3, None))
4757+
self.assertEqual(len(caught), 2)
4758+
for warning, name in zip(caught, 'bc'):
4759+
self.assertIs(warning.category, DeprecationWarning)
4760+
self.assertRegex(str(warning.message), errmsg(name))
47534761

47544762
def test_lone_kwds(self):
47554763
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)