diff options
| author | Facundo Batista <facundobatista@gmail.com> | 2008-01-08 12:25:20 (GMT) |
|---|---|---|
| committer | Facundo Batista <facundobatista@gmail.com> | 2008-01-08 12:25:20 (GMT) |
| commit | 52b25795c02442fc40f8932d05e5d728266339a4 (patch) | |
| tree | 6bd1515a655c8d46c892a9044f2aa10cf78152c8 /Lib/test/test_decimal.py | |
| parent | f66f95d419776bdb4fe0d3c9b8d848d3321a645b (diff) | |
| download | cpython-52b25795c02442fc40f8932d05e5d728266339a4.zip cpython-52b25795c02442fc40f8932d05e5d728266339a4.tar.gz cpython-52b25795c02442fc40f8932d05e5d728266339a4.tar.bz2 | |
Issue #1757: The hash of a Decimal instance is no longer affected
by the current context. Thanks Mark Dickinson.
Diffstat (limited to 'Lib/test/test_decimal.py')
| -rw-r--r-- | Lib/test/test_decimal.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index dbe7023..03cff60 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -980,6 +980,23 @@ class DecimalUsabilityTest(unittest.TestCase): self.assert_(hash(Decimal('Inf'))) self.assert_(hash(Decimal('-Inf'))) + # check that the value of the hash doesn't depend on the + # current context (issue #1757) + c = getcontext() + old_precision = c.prec + x = Decimal("123456789.1") + + c.prec = 6 + h1 = hash(x) + c.prec = 10 + h2 = hash(x) + c.prec = 16 + h3 = hash(x) + + self.assertEqual(h1, h2) + self.assertEqual(h1, h3) + c.prec = old_precision + def test_min_and_max_methods(self): d1 = Decimal('15.32') |
