Commit dfe21074 authored by Ezio Melotti's avatar Ezio Melotti

Fix deprecation warnings in test_file.py

parent cd37dd8e
...@@ -34,11 +34,14 @@ class AutoFileTests(unittest.TestCase): ...@@ -34,11 +34,14 @@ class AutoFileTests(unittest.TestCase):
def testAttributes(self): def testAttributes(self):
# verify expected attributes exist # verify expected attributes exist
f = self.f f = self.f
softspace = f.softspace
f.name # merely shouldn't blow up f.name # merely shouldn't blow up
f.mode # ditto f.mode # ditto
f.closed # ditto f.closed # ditto
with test_support._check_py3k_warnings(
('file.softspace not supported in 3.x', DeprecationWarning)):
softspace = f.softspace
# verify softspace is writable # verify softspace is writable
f.softspace = softspace # merely shouldn't blow up f.softspace = softspace # merely shouldn't blow up
...@@ -111,6 +114,7 @@ class AutoFileTests(unittest.TestCase): ...@@ -111,6 +114,7 @@ class AutoFileTests(unittest.TestCase):
for methodname in methods: for methodname in methods:
method = getattr(self.f, methodname) method = getattr(self.f, methodname)
# should raise on closed file # should raise on closed file
with test_support._check_py3k_warnings(quiet=True):
self.assertRaises(ValueError, method) self.assertRaises(ValueError, method)
self.assertRaises(ValueError, self.f.writelines, []) self.assertRaises(ValueError, self.f.writelines, [])
...@@ -218,7 +222,7 @@ class OtherFileTests(unittest.TestCase): ...@@ -218,7 +222,7 @@ class OtherFileTests(unittest.TestCase):
try: try:
f = open(TESTFN, bad_mode) f = open(TESTFN, bad_mode)
except ValueError, msg: except ValueError, msg:
if msg[0] != 0: if msg.args[0] != 0:
s = str(msg) s = str(msg)
if TESTFN in s or bad_mode not in s: if TESTFN in s or bad_mode not in s:
self.fail("bad error message for invalid mode: %s" % s) self.fail("bad error message for invalid mode: %s" % s)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment