Fixing - Issue7026 - RuntimeError: dictionary changed size during iteration. Patch by flox

This commit is contained in:
Senthil Kumaran 2010-01-08 18:41:40 +00:00
parent 3194d1454c
commit 3ddc435af6
107 changed files with 794 additions and 436 deletions

View file

@ -34,13 +34,17 @@ class AutoFileTests(unittest.TestCase):
def testAttributes(self):
# verify expected attributes exist
f = self.f
softspace = f.softspace
# Silence Py3k warning
with test_support.check_warnings():
softspace = f.softspace
f.name # merely shouldn't blow up
f.mode # ditto
f.closed # ditto
# verify softspace is writable
f.softspace = softspace # merely shouldn't blow up
# Silence Py3k warning
with test_support.check_warnings():
# verify softspace is writable
f.softspace = softspace # merely shouldn't blow up
# verify the others aren't
for attr in 'name', 'mode', 'closed':
@ -98,7 +102,8 @@ class AutoFileTests(unittest.TestCase):
def testMethods(self):
methods = ['fileno', 'flush', 'isatty', 'next', 'read', 'readinto',
'readline', 'readlines', 'seek', 'tell', 'truncate',
'write', 'xreadlines', '__iter__']
'write', '__iter__']
deprecated_methods = ['xreadlines']
if sys.platform.startswith('atheos'):
methods.remove('truncate')
@ -110,13 +115,18 @@ class AutoFileTests(unittest.TestCase):
method = getattr(self.f, methodname)
# should raise on closed file
self.assertRaises(ValueError, method)
# Silence Py3k warning
with test_support.check_warnings():
for methodname in deprecated_methods:
method = getattr(self.f, methodname)
self.assertRaises(ValueError, method)
self.assertRaises(ValueError, self.f.writelines, [])
# file is closed, __exit__ shouldn't do anything
self.assertEquals(self.f.__exit__(None, None, None), None)
# it must also return None if an exception was given
try:
1/0
1 // 0
except:
self.assertEquals(self.f.__exit__(*sys.exc_info()), None)
@ -182,12 +192,12 @@ class OtherFileTests(unittest.TestCase):
try:
f = open(TESTFN, bad_mode)
except ValueError, msg:
if msg[0] != 0:
if msg.args[0] != 0:
s = str(msg)
if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
self.fail("bad error message for invalid mode: %s" % s)
# if msg[0] == 0, we're probably on Windows where there may be
# no obvious way to discover why open() failed.
# if msg.args[0] == 0, we're probably on Windows where there may
# be no obvious way to discover why open() failed.
else:
f.close()
self.fail("no error for invalid mode: %s" % bad_mode)