Fix tests dependent on the exception raised by non-settable descriptors.

This commit is contained in:
Barry Warsaw 2005-04-20 19:41:36 +00:00
parent e890682e52
commit b180c06a54
3 changed files with 6 additions and 5 deletions

View File

@ -55,8 +55,9 @@ class Test_Csv(unittest.TestCase):
# Try deleting or changing attributes (they are read-only)
self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter')
self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':')
self.assertRaises(TypeError, delattr, obj.dialect, 'quoting')
self.assertRaises(TypeError, setattr, obj.dialect, 'quoting', None)
self.assertRaises(AttributeError, delattr, obj.dialect, 'quoting')
self.assertRaises(AttributeError, setattr, obj.dialect,
'quoting', None)
def test_reader_attrs(self):
self._test_default_attrs(csv.reader, [])

View File

@ -2712,7 +2712,7 @@ def setdict():
def cant(x, dict):
try:
x.__dict__ = dict
except TypeError:
except (AttributeError, TypeError):
pass
else:
raise TestFailed, "shouldn't allow %r.__dict__ = %r" % (x, dict)

View File

@ -34,10 +34,10 @@ f.softspace = softspace # merely shouldn't blow up
for attr in 'name', 'mode', 'closed':
try:
setattr(f, attr, 'oops')
except TypeError:
except (AttributeError, TypeError):
pass
else:
raise TestFailed('expected TypeError setting file attr %r' % attr)
raise TestFailed('expected exception setting file attr %r' % attr)
f.close()
# verify writelines with instance sequence