https://github.com/python/cpython/commit/485d2e831ebf71a34634319adeeabdd1f9158bbe
commit: 485d2e831ebf71a34634319adeeabdd1f9158bbe
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-01-20T11:20:49+02:00
summary:
gh-71339: Use assertIsSubclass() and assertNotIsSubclass() in test_decimal
(GH-128827)
files:
M Lib/test/test_decimal.py
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index bc6c6427740949..02d3fa985e75b9 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -752,7 +752,7 @@ def test_explicit_context_create_decimal(self):
for v in [-2**63-1, -2**63, -2**31-1, -2**31, 0,
2**31-1, 2**31, 2**63-1, 2**63]:
d = nc.create_decimal(v)
- self.assertTrue(isinstance(d, Decimal))
+ self.assertIsInstance(d, Decimal)
self.assertEqual(int(d), v)
nc.prec = 3
@@ -2590,8 +2590,8 @@ class PythonAPItests:
def test_abc(self):
Decimal = self.decimal.Decimal
- self.assertTrue(issubclass(Decimal, numbers.Number))
- self.assertFalse(issubclass(Decimal, numbers.Real))
+ self.assertIsSubclass(Decimal, numbers.Number)
+ self.assertNotIsSubclass(Decimal, numbers.Real)
self.assertIsInstance(Decimal(0), numbers.Number)
self.assertNotIsInstance(Decimal(0), numbers.Real)
@@ -2690,7 +2690,7 @@ class MyDecimal(Decimal):
def __init__(self, _):
self.x = 'y'
- self.assertTrue(issubclass(MyDecimal, Decimal))
+ self.assertIsSubclass(MyDecimal, Decimal)
r = MyDecimal.from_float(0.1)
self.assertEqual(type(r), MyDecimal)
@@ -2908,31 +2908,31 @@ def test_exception_hierarchy(self):
Rounded = decimal.Rounded
Clamped = decimal.Clamped
- self.assertTrue(issubclass(DecimalException, ArithmeticError))
-
- self.assertTrue(issubclass(InvalidOperation, DecimalException))
- self.assertTrue(issubclass(FloatOperation, DecimalException))
- self.assertTrue(issubclass(FloatOperation, TypeError))
- self.assertTrue(issubclass(DivisionByZero, DecimalException))
- self.assertTrue(issubclass(DivisionByZero, ZeroDivisionError))
- self.assertTrue(issubclass(Overflow, Rounded))
- self.assertTrue(issubclass(Overflow, Inexact))
- self.assertTrue(issubclass(Overflow, DecimalException))
- self.assertTrue(issubclass(Underflow, Inexact))
- self.assertTrue(issubclass(Underflow, Rounded))
- self.assertTrue(issubclass(Underflow, Subnormal))
- self.assertTrue(issubclass(Underflow, DecimalException))
-
- self.assertTrue(issubclass(Subnormal, DecimalException))
- self.assertTrue(issubclass(Inexact, DecimalException))
- self.assertTrue(issubclass(Rounded, DecimalException))
- self.assertTrue(issubclass(Clamped, DecimalException))
-
- self.assertTrue(issubclass(decimal.ConversionSyntax, InvalidOperation))
- self.assertTrue(issubclass(decimal.DivisionImpossible,
InvalidOperation))
- self.assertTrue(issubclass(decimal.DivisionUndefined,
InvalidOperation))
- self.assertTrue(issubclass(decimal.DivisionUndefined,
ZeroDivisionError))
- self.assertTrue(issubclass(decimal.InvalidContext, InvalidOperation))
+ self.assertIsSubclass(DecimalException, ArithmeticError)
+
+ self.assertIsSubclass(InvalidOperation, DecimalException)
+ self.assertIsSubclass(FloatOperation, DecimalException)
+ self.assertIsSubclass(FloatOperation, TypeError)
+ self.assertIsSubclass(DivisionByZero, DecimalException)
+ self.assertIsSubclass(DivisionByZero, ZeroDivisionError)
+ self.assertIsSubclass(Overflow, Rounded)
+ self.assertIsSubclass(Overflow, Inexact)
+ self.assertIsSubclass(Overflow, DecimalException)
+ self.assertIsSubclass(Underflow, Inexact)
+ self.assertIsSubclass(Underflow, Rounded)
+ self.assertIsSubclass(Underflow, Subnormal)
+ self.assertIsSubclass(Underflow, DecimalException)
+
+ self.assertIsSubclass(Subnormal, DecimalException)
+ self.assertIsSubclass(Inexact, DecimalException)
+ self.assertIsSubclass(Rounded, DecimalException)
+ self.assertIsSubclass(Clamped, DecimalException)
+
+ self.assertIsSubclass(decimal.ConversionSyntax, InvalidOperation)
+ self.assertIsSubclass(decimal.DivisionImpossible, InvalidOperation)
+ self.assertIsSubclass(decimal.DivisionUndefined, InvalidOperation)
+ self.assertIsSubclass(decimal.DivisionUndefined, ZeroDivisionError)
+ self.assertIsSubclass(decimal.InvalidContext, InvalidOperation)
@requires_cdecimal
class CPythonAPItests(PythonAPItests, unittest.TestCase):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]