Skip to content

Commit

Permalink
address review: tests (few more, reformatting, etc)
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Sep 22, 2024
1 parent a917cef commit e8f49b0
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Lib/test/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -2505,44 +2505,37 @@ 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}"):
math.sqrt(x)

with self.assertRaises(ValueError,
msg=f"expected a positive input, got {x}"):
math.log(x)
with self.assertRaises(ValueError,
msg=f"expected a positive input, got {x}"):
math.log(123, x)
with self.assertRaises(ValueError,
msg=f"expected a positive input, got {x}"):
math.log(x, 123)
with self.assertRaises(ValueError,
msg=f"expected a positive input, got {x}"):
math.log2(x)
with self.assertRaises(ValueError,
msg=f"expected a positive input, got {x}"):
math.log2(x)

x = decimal.Decimal(x)

x = decimal.Decimal('-1.1')
with self.assertRaises(ValueError,
msg=f"expected a positive input, got {x!r}"):
math.log(x)

x = fractions.Fraction(1, 10**400)

with self.assertRaises(ValueError,
msg=f"expected a positive input, got {float(x)!r}"):
math.log(x)

x = -2**1000

x = -123
with self.assertRaises(ValueError,
msg=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}"):
math.atanh(x)
Expand Down

0 comments on commit e8f49b0

Please sign in to comment.