#7092: silence some more py3k warnings.
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py
index d812927..f692533 100644
--- a/Lib/test/test_file2k.py
+++ b/Lib/test/test_file2k.py
@@ -34,13 +34,15 @@
def testAttributes(self):
# verify expected attributes exist
f = self.f
- softspace = f.softspace
+ with test_support.check_py3k_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
+ with test_support.check_py3k_warnings():
+ # verify softspace is writable
+ f.softspace = softspace # merely shouldn't blow up
# verify the others aren't
for attr in 'name', 'mode', 'closed':
@@ -100,7 +102,8 @@
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')
@@ -112,13 +115,17 @@
method = getattr(self.f, methodname)
# should raise on closed file
self.assertRaises(ValueError, method)
+ with test_support.check_py3k_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)
@@ -218,12 +225,12 @@
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)