summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_decimal.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-05-22 18:35:36 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-05-22 18:35:36 (GMT)
commitb1d8e3229c3127960ab6d7314ca8014f5e6459c0 (patch)
tree0eb0113b42860d4b380c19d43c64cbb73ec3cf2d /Lib/test/test_decimal.py
parenta92ad7ee2cfd4e81c22a7715aa0278196d9da664 (diff)
downloadcpython-b1d8e3229c3127960ab6d7314ca8014f5e6459c0.zip
cpython-b1d8e3229c3127960ab6d7314ca8014f5e6459c0.tar.gz
cpython-b1d8e3229c3127960ab6d7314ca8014f5e6459c0.tar.bz2
#Issue 8540: Make Context._clamp attribute public in decimal module.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r--Lib/test/test_decimal.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 2159088..50b660b 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -27,11 +27,13 @@ with the corresponding argument.
import math
import os, sys
import operator
+import warnings
import pickle, copy
import unittest
from decimal import *
import numbers
from test.support import run_unittest, run_doctest, is_resource_enabled
+from test.support import check_warnings
import random
try:
import threading
@@ -412,7 +414,7 @@ class DecimalTest(unittest.TestCase):
def change_max_exponent(self, exp):
self.context.Emax = exp
def change_clamp(self, clamp):
- self.context._clamp = clamp
+ self.context.clamp = clamp
@@ -1815,6 +1817,26 @@ class ContextAPItests(unittest.TestCase):
self.assertNotEqual(id(c.flags), id(d.flags))
self.assertNotEqual(id(c.traps), id(d.traps))
+ def test__clamp(self):
+ # In Python 3.2, the private attribute `_clamp` was made
+ # public (issue 8540), with the old `_clamp` becoming a
+ # property wrapping `clamp`. For the duration of Python 3.2
+ # only, the attribute should be gettable/settable via both
+ # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be
+ # removed.
+ c = Context(clamp = 0)
+ self.assertEqual(c.clamp, 0)
+
+ with check_warnings(("", DeprecationWarning)):
+ c._clamp = 1
+ self.assertEqual(c.clamp, 1)
+ with check_warnings(("", DeprecationWarning)):
+ self.assertEqual(c._clamp, 1)
+ c.clamp = 0
+ self.assertEqual(c.clamp, 0)
+ with check_warnings(("", DeprecationWarning)):
+ self.assertEqual(c._clamp, 0)
+
def test_abs(self):
c = Context()
d = c.abs(Decimal(-1))