summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-04-03 14:59:49 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-04-03 14:59:49 (GMT)
commit6607d51160c76df157813cbc711ffe4bdf2a60eb (patch)
treeca68ab924abc2a352409427f3d6a3c9986e1b508 /Lib
parent77e2b67971e240a1a66a29dfe87448f83f7d0014 (diff)
downloadcpython-6607d51160c76df157813cbc711ffe4bdf2a60eb.zip
cpython-6607d51160c76df157813cbc711ffe4bdf2a60eb.tar.gz
cpython-6607d51160c76df157813cbc711ffe4bdf2a60eb.tar.bz2
Merged revisions 79678 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79678 | ezio.melotti | 2010-04-03 17:51:00 +0300 (Sat, 03 Apr 2010) | 1 line Use more specific assert* methods in test_decimal. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_decimal.py80
1 files changed, 40 insertions, 40 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 7de2400..d6e170d 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1225,18 +1225,18 @@ class DecimalUsabilityTest(unittest.TestCase):
dc = Decimal('45')
#two Decimals
- self.assertTrue(dc > da)
- self.assertTrue(dc >= da)
- self.assertTrue(da < dc)
- self.assertTrue(da <= dc)
+ self.assertGreater(dc, da)
+ self.assertGreaterEqual(dc, da)
+ self.assertLess(da, dc)
+ self.assertLessEqual(da, dc)
self.assertEqual(da, db)
- self.assertTrue(da != dc)
- self.assertTrue(da <= db)
- self.assertTrue(da >= db)
+ self.assertNotEqual(da, dc)
+ self.assertLessEqual(da, db)
+ self.assertGreaterEqual(da, db)
#a Decimal and an int
- self.assertTrue(dc > 23)
- self.assertTrue(23 < dc)
+ self.assertGreater(dc, 23)
+ self.assertLess(23, dc)
self.assertEqual(dc, 45)
#a Decimal and uncomparable
@@ -1255,19 +1255,19 @@ class DecimalUsabilityTest(unittest.TestCase):
def test_decimal_float_comparison(self):
da = Decimal('0.25')
db = Decimal('3.0')
- self.assert_(da < 3.0)
- self.assert_(da <= 3.0)
- self.assert_(db > 0.25)
- self.assert_(db >= 0.25)
- self.assert_(da != 1.5)
- self.assert_(da == 0.25)
- self.assert_(3.0 > da)
- self.assert_(3.0 >= da)
- self.assert_(0.25 < db)
- self.assert_(0.25 <= db)
- self.assert_(0.25 != db)
- self.assert_(3.0 == db)
- self.assert_(0.1 != Decimal('0.1'))
+ self.assertLess(da, 3.0)
+ self.assertLessEqual(da, 3.0)
+ self.assertGreater(db, 0.25)
+ self.assertGreaterEqual(db, 0.25)
+ self.assertNotEqual(da, 1.5)
+ self.assertEqual(da, 0.25)
+ self.assertGreater(3.0, da)
+ self.assertGreaterEqual(3.0, da)
+ self.assertLess(0.25, db)
+ self.assertLessEqual(0.25, db)
+ self.assertNotEqual(0.25, db)
+ self.assertEqual(3.0, db)
+ self.assertNotEqual(0.1, Decimal('0.1'))
def test_copy_and_deepcopy_methods(self):
d = Decimal('43.24')
@@ -1355,16 +1355,16 @@ class DecimalUsabilityTest(unittest.TestCase):
l2 = 28
#between Decimals
- self.assertTrue(min(d1,d2) is d1)
- self.assertTrue(min(d2,d1) is d1)
- self.assertTrue(max(d1,d2) is d2)
- self.assertTrue(max(d2,d1) is d2)
+ self.assertIs(min(d1,d2), d1)
+ self.assertIs(min(d2,d1), d1)
+ self.assertIs(max(d1,d2), d2)
+ self.assertIs(max(d2,d1), d2)
#between Decimal and long
- self.assertTrue(min(d1,l2) is d1)
- self.assertTrue(min(l2,d1) is d1)
- self.assertTrue(max(l1,d2) is d2)
- self.assertTrue(max(d2,l1) is d2)
+ self.assertIs(min(d1,l2), d1)
+ self.assertIs(min(l2,d1), d1)
+ self.assertIs(max(l1,d2), d2)
+ self.assertIs(max(d2,l1), d2)
def test_as_nonzero(self):
#as false
@@ -1621,10 +1621,10 @@ class DecimalUsabilityTest(unittest.TestCase):
d1 = MyDecimal(1)
d2 = MyDecimal(2)
d = d1 + d2
- self.assertTrue(type(d) is Decimal)
+ self.assertIs(type(d), Decimal)
d = d1.max(d2)
- self.assertTrue(type(d) is Decimal)
+ self.assertIs(type(d), Decimal)
def test_implicit_context(self):
# Check results when context given implicitly. (Issue 2478)
@@ -1684,7 +1684,7 @@ class DecimalPythonAPItests(unittest.TestCase):
def test_abc(self):
self.assertTrue(issubclass(Decimal, numbers.Number))
- self.assertTrue(not issubclass(Decimal, numbers.Real))
+ self.assertFalse(issubclass(Decimal, numbers.Real))
self.assertIsInstance(Decimal(0), numbers.Number)
self.assertNotIsInstance(Decimal(0), numbers.Real)
@@ -2232,9 +2232,9 @@ class WithStatementTest(unittest.TestCase):
with localcontext() as enter_ctx:
set_ctx = getcontext()
final_ctx = getcontext()
- self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly')
- self.assertTrue(orig_ctx is not set_ctx, 'did not copy the context')
- self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context')
+ self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
+ self.assertIsNot(orig_ctx, set_ctx, 'did not copy the context')
+ self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
def test_localcontextarg(self):
# Use a copy of the supplied context in the block
@@ -2243,10 +2243,10 @@ class WithStatementTest(unittest.TestCase):
with localcontext(new_ctx) as enter_ctx:
set_ctx = getcontext()
final_ctx = getcontext()
- self.assertTrue(orig_ctx is final_ctx, 'did not restore context correctly')
- self.assertTrue(set_ctx.prec == new_ctx.prec, 'did not set correct context')
- self.assertTrue(new_ctx is not set_ctx, 'did not copy the context')
- self.assertTrue(set_ctx is enter_ctx, '__enter__ returned wrong context')
+ self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
+ self.assertEqual(set_ctx.prec, new_ctx.prec, 'did not set correct context')
+ self.assertIsNot(new_ctx, set_ctx, 'did not copy the context')
+ self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
class ContextFlags(unittest.TestCase):
def test_flags_irrelevant(self):