import copy as _copy
import math as _math
+import numbers as _numbers
try:
from collections import namedtuple as _namedtuple
return self
+# Register Decimal as a kind of Number (an abstract base class).
+# However, do not register it as Real (because Decimals are not
+# interoperable with floats).
+_numbers.Number.register(Decimal)
+
+
##### Context class #######################################################
import pickle, copy
import unittest
from decimal import *
+import numbers
from test.support import (TestSkipped, run_unittest, run_doctest,
is_resource_enabled)
import random
class DecimalPythonAPItests(unittest.TestCase):
+ def test_abc(self):
+ self.assert_(issubclass(Decimal, numbers.Number))
+ self.assert_(not issubclass(Decimal, numbers.Real))
+ self.assert_(isinstance(Decimal(0), numbers.Number))
+ self.assert_(not isinstance(Decimal(0), numbers.Real))
+
def test_pickle(self):
d = Decimal('-3.141590000')
p = pickle.dumps(d)