diff options
| author | Senthil Kumaran <orsenthil@gmail.com> | 2010-01-08 18:41:40 (GMT) |
|---|---|---|
| committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-01-08 18:41:40 (GMT) |
| commit | 3ddc435af6873c6304058d7bcbcb19ee4fba7781 (patch) | |
| tree | c7a03cf0a8b856bae2ebebba55b09f775845c7ca /Lib/test/test_decimal.py | |
| parent | 3194d1454cbc11ec477d83fff3fc749972107d29 (diff) | |
| download | cpython-3ddc435af6873c6304058d7bcbcb19ee4fba7781.zip cpython-3ddc435af6873c6304058d7bcbcb19ee4fba7781.tar.gz cpython-3ddc435af6873c6304058d7bcbcb19ee4fba7781.tar.bz2 | |
Fixing - Issue7026 - RuntimeError: dictionary changed size during iteration. Patch by flox
Diffstat (limited to 'Lib/test/test_decimal.py')
| -rw-r--r-- | Lib/test/test_decimal.py | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 69f31a0..9fef0d2 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -31,7 +31,8 @@ import pickle, copy import unittest from decimal import * import numbers -from test.test_support import (run_unittest, run_doctest, is_resource_enabled) +from test.test_support import (run_unittest, run_doctest, + is_resource_enabled, check_warnings) import random try: import threading @@ -202,7 +203,7 @@ class DecimalTest(unittest.TestCase): if skip_expected: raise unittest.SkipTest return - for line in open(file).xreadlines(): + for line in open(file): line = line.replace('\r\n', '').replace('\n', '') #print line try: @@ -361,8 +362,10 @@ class DecimalTest(unittest.TestCase): myexceptions = self.getexceptions() self.context.clear_flags() - myexceptions.sort() - theirexceptions.sort() + # Silence Py3k warning + with check_warnings(): + myexceptions.sort() + theirexceptions.sort() self.assertEqual(result, ans, 'Incorrect answer for ' + s + ' -- got ' + result) @@ -617,12 +620,14 @@ 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__')) + # Silence Py3k warning + with check_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)) @@ -1194,8 +1199,10 @@ class DecimalUsabilityTest(unittest.TestCase): self.assertEqual(a, b) # with None - self.assertFalse(Decimal(1) < None) - self.assertTrue(Decimal(1) > None) + # Silence Py3k warning + with check_warnings(): + self.assertFalse(Decimal(1) < None) + self.assertTrue(Decimal(1) > None) def test_copy_and_deepcopy_methods(self): d = Decimal('43.24') @@ -1704,11 +1711,14 @@ class ContextFlags(unittest.TestCase): for flag in extra_flags: if flag not in expected_flags: expected_flags.append(flag) - expected_flags.sort() # flags we actually got new_flags = [k for k,v in context.flags.items() if v] - new_flags.sort() + + # Silence Py3k warning + with check_warnings(): + expected_flags.sort() + new_flags.sort() self.assertEqual(ans, new_ans, "operation produces different answers depending on flags set: " + |
