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: tests (few more, reformatting, etc)
  • Loading branch information
skirpichev committed Sep 22, 2024
commit e8f49b0f6a1cb2831d6d89c8dc7ee78e6857b095
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}"):
Comment thread
skirpichev marked this conversation as resolved.
Outdated
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}"):
Comment thread
skirpichev marked this conversation as resolved.
Outdated
math.log(123, x)
Comment thread
skirpichev marked this conversation as resolved.
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)
Comment thread
skirpichev marked this conversation as resolved.

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}"):
Comment thread
skirpichev marked this conversation as resolved.
Outdated
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