From e9bf987cce75b136e7551c0cafe4ab80b0ca9839 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 30 Sep 2024 04:42:07 +0300 Subject: [PATCH] address review: assertRaises -> assertRaisesRegex --- Lib/test/test_math.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 8ec643e4639da6..acc0a5ffb07fa6 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -2505,39 +2505,39 @@ def test_input_exceptions(self): def test_exception_messages(self): x = -1.1 - with self.assertRaises(ValueError, - msg=f"expected a nonnegative input, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a nonnegative input, got {x}"): math.sqrt(x) - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {x}"): math.log(x) - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {x}"): math.log(123, x) - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {x}"): math.log(x, 123) - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {x}"): math.log2(x) - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {x}"): math.log10(x) x = decimal.Decimal('-1.1') - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {x!r}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {x}"): math.log(x) x = fractions.Fraction(1, 10**400) - with self.assertRaises(ValueError, - msg=f"expected a positive input, got {float(x)}"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input, got {float(x)}"): math.log(x) x = -123 - with self.assertRaises(ValueError, - msg=f"expected a positive input"): + with self.assertRaisesRegex(ValueError, + f"expected a positive input"): math.log(x) x = 1.0 - with self.assertRaises(ValueError, - msg=f"expected a number between -1 and 1, got {x}"): + with self.assertRaisesRegex(ValueError, + f"expected a number between -1 and 1, got {x}"): math.atanh(x) # Custom assertions.