Skip to content

Commit

Permalink
address review: assertRaises -> assertRaisesRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Sep 30, 2024
1 parent 0bdbc72 commit e9bf987
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e9bf987

Please sign in to comment.