Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review: assertRaises -> assertRaisesRegex
  • Loading branch information
skirpichev committed Sep 30, 2024
commit e9bf987cce75b136e7551c0cafe4ab80b0ca9839
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)
Comment thread
skirpichev marked this conversation as resolved.
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)
Comment thread
skirpichev marked this conversation as resolved.
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"):
Comment thread
skirpichev marked this conversation as resolved.
Outdated
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