diff options
author | Stefan Krah <skrah@bytereef.org> | 2013-05-29 16:50:06 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2013-05-29 16:50:06 (GMT) |
commit | 2e537f9edcf8ed3bd2418b08957c990d90b0c720 (patch) | |
tree | 4d54b115528c225ef08da0b02dd745b621d0f567 /Lib/test | |
parent | 1cfebc73e0ecbcde0b564567606882d70c7812ec (diff) | |
download | cpython-2e537f9edcf8ed3bd2418b08957c990d90b0c720.zip cpython-2e537f9edcf8ed3bd2418b08957c990d90b0c720.tar.gz cpython-2e537f9edcf8ed3bd2418b08957c990d90b0c720.tar.bz2 |
test_decimal: add __sizeof__() tests for code coverage.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_decimal.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 7dd287e..ae36893 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -5372,6 +5372,19 @@ class CWhitebox(unittest.TestCase): x = (1, (0, 1), "N") self.assertEqual(str(Decimal(x)), '-sNaN1') + def test_sizeof(self): + Decimal = C.Decimal + HAVE_CONFIG_64 = (C.MAX_PREC > 425000000) + + self.assertGreater(Decimal(0).__sizeof__(), 0) + if HAVE_CONFIG_64: + x = Decimal(10**(19*24)).__sizeof__() + y = Decimal(10**(19*25)).__sizeof__() + self.assertEqual(y, x+8) + else: + x = Decimal(10**(9*24)).__sizeof__() + y = Decimal(10**(9*25)).__sizeof__() + self.assertEqual(y, x+4) all_tests = [ CExplicitConstructionTest, PyExplicitConstructionTest, |