diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2010-08-03 04:08:59 +0000 |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2010-08-03 04:08:59 +0000 |
commit | d24b5d8fc786ba0532aebf24db21ed097446514f (patch) | |
tree | 2486431a7b0622a0e54195b26ef4a1ddb773f662 /Lib/test/test_decimal.py | |
parent | 620f5c91d78f2b8d5600e838ec3a33f109b89bb3 (diff) | |
download | cpython-git-d24b5d8fc786ba0532aebf24db21ed097446514f.tar.gz |
Merged revisions 79187-79189 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79187 | florent.xicluna | 2010-03-21 12:50:44 +0200 (Sun, 21 Mar 2010) | 2 lines
Silence more py3k warnings in unittest.case.
........
r79188 | florent.xicluna | 2010-03-21 12:51:40 +0200 (Sun, 21 Mar 2010) | 2 lines
Fix py3k warnings in test_decimal, using unittest.assertItemsEqual.
........
r79189 | florent.xicluna | 2010-03-21 13:03:21 +0200 (Sun, 21 Mar 2010) | 2 lines
Silence some py3k SyntaxWarning using check_py3k_warnings() with "exec" statements.
........
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index cc15c330fe..41767c3b48 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -32,7 +32,7 @@ import unittest from decimal import * import numbers from test.test_support import (TestSkipped, run_unittest, run_doctest, - is_resource_enabled) + is_resource_enabled, _check_py3k_warnings) import random try: import threading @@ -219,7 +219,7 @@ class DecimalTest(unittest.TestCase): if skip_expected: raise TestSkipped return - for line in open(file).xreadlines(): + for line in open(file): line = line.replace('\r\n', '').replace('\n', '') #print line try: @@ -381,8 +381,9 @@ class DecimalTest(unittest.TestCase): myexceptions = self.getexceptions() self.context.clear_flags() - myexceptions.sort() - theirexceptions.sort() + with _check_py3k_warnings(quiet=True): + myexceptions.sort() + theirexceptions.sort() self.assertEqual(result, ans, 'Incorrect answer for ' + s + ' -- got ' + result) @@ -637,12 +638,13 @@ class DecimalImplicitConstructionTest(unittest.TestCase): ('//', '__floordiv__', '__rfloordiv__'), ('**', '__pow__', '__rpow__') ] - if 1/2 == 0: - # testing with classic division, so add __div__ - oplist.append(('/', '__div__', '__rdiv__')) - else: - # testing with -Qnew, so add __truediv__ - oplist.append(('/', '__truediv__', '__rtruediv__')) + with _check_py3k_warnings(): + if 1 / 2 == 0: + # testing with classic division, so add __div__ + oplist.append(('/', '__div__', '__rdiv__')) + else: + # testing with -Qnew, so add __truediv__ + oplist.append(('/', '__truediv__', '__rtruediv__')) for sym, lop, rop in oplist: setattr(E, lop, lambda self, other: 'str' + lop + str(other)) @@ -1095,8 +1097,9 @@ class DecimalUsabilityTest(unittest.TestCase): self.assertEqual(a, b) # with None - self.assertFalse(Decimal(1) < None) - self.assertTrue(Decimal(1) > None) + with _check_py3k_warnings(): + self.assertFalse(Decimal(1) < None) + self.assertTrue(Decimal(1) > None) def test_copy_and_deepcopy_methods(self): d = Decimal('43.24') @@ -1556,18 +1559,20 @@ class ContextFlags(unittest.TestCase): for flag in extra_flags: if flag not in expected_flags: expected_flags.append(flag) - expected_flags.sort() + with _check_py3k_warnings(quiet=True): + expected_flags.sort() # flags we actually got new_flags = [k for k,v in context.flags.items() if v] - new_flags.sort() + with _check_py3k_warnings(quiet=True): + new_flags.sort() self.assertEqual(ans, new_ans, "operation produces different answers depending on flags set: " + "expected %s, got %s." % (ans, new_ans)) self.assertEqual(new_flags, expected_flags, - "operation raises different flags depending on flags set: " + - "expected %s, got %s" % (expected_flags, new_flags)) + "operation raises different flags depending on flags set: " + + "expected %s, got %s" % (expected_flags, new_flags)) def test_main(arith=False, verbose=None, todo_tests=None, debug=None): """ Execute the tests. |