[Python-checkins] cpython (2.7): Silence deprecation warning in test_mmap for ValueError.message.

terry.reedy python-checkins at python.org
Sun Sep 1 03:14:21 CEST 2013


http://hg.python.org/cpython/rev/869d50357a71
changeset:   85484:869d50357a71
branch:      2.7
user:        Terry Jan Reedy <tjreedy at udel.edu>
date:        Sat Aug 31 21:14:00 2013 -0400
summary:
  Silence deprecation warning in test_mmap for ValueError.message.
Replacement is from 3.3, with 'p' added to make '...Regexp'.

files:
  Lib/test/test_mmap.py |  12 ++++--------
  1 files changed, 4 insertions(+), 8 deletions(-)


diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -470,14 +470,10 @@
         f = open (TESTFN, 'w+b')
         f.close()
         with open(TESTFN, "rb") as f :
-            try:
-                m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
-                m.close()
-                self.fail("should not have been able to mmap empty file")
-            except ValueError as e:
-                self.assertEqual(e.message, "cannot mmap an empty file")
-            except:
-                self.fail("unexpected exception: " + str(e))
+            self.assertRaisesRegexp(ValueError,
+                                   "cannot mmap an empty file",
+                                   mmap.mmap, f.fileno(), 0,
+                                   access=mmap.ACCESS_READ)
 
     def test_offset (self):
         f = open (TESTFN, 'w+b')

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list