]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix deprecation warnings in test_file.py
authorEzio Melotti <ezio.melotti@gmail.com>
Tue, 3 Aug 2010 07:17:20 +0000 (07:17 +0000)
committerEzio Melotti <ezio.melotti@gmail.com>
Tue, 3 Aug 2010 07:17:20 +0000 (07:17 +0000)
Lib/test/test_file.py

index 5ee037dce30d69ef69a52864af000868d64434ff..744454832fa54ff5864c86a624cdfd9da5178ea4 100644 (file)
@@ -34,13 +34,16 @@ class AutoFileTests(unittest.TestCase):
     def testAttributes(self):
         # verify expected attributes exist
         f = self.f
-        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(
+            ('file.softspace not supported in 3.x', DeprecationWarning)):
+            softspace = f.softspace
+            # verify softspace is writable
+            f.softspace = softspace    # merely shouldn't blow up
 
         # verify the others aren't
         for attr in 'name', 'mode', 'closed':
@@ -111,7 +114,8 @@ class AutoFileTests(unittest.TestCase):
         for methodname in methods:
             method = getattr(self.f, methodname)
             # should raise on closed file
-            self.assertRaises(ValueError, method)
+            with test_support._check_py3k_warnings(quiet=True):
+                self.assertRaises(ValueError, method)
         self.assertRaises(ValueError, self.f.writelines, [])
 
         # file is closed, __exit__ shouldn't do anything
@@ -218,7 +222,7 @@ 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 TESTFN in s or bad_mode not in s:
                     self.fail("bad error message for invalid mode: %s" % s)