From: Terry Jan Reedy Date: Sun, 1 Sep 2013 01:14:00 +0000 (-0400) Subject: Silence deprecation warning in test_mmap for ValueError.message. X-Git-Tag: v2.7.6rc1~182 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71b2ded05e55a044cbba9257ed43ed34b5e9648c;p=thirdparty%2FPython%2Fcpython.git Silence deprecation warning in test_mmap for ValueError.message. Replacement is from 3.3, with 'p' added to make '...Regexp'. --- diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index f84b20aa441a..9fd218418ce5 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -470,14 +470,10 @@ class MmapTests(unittest.TestCase): 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')