#8046: add context manager protocol support to mmap objects.  Also add closed property.
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index c27b898..68af00e 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -586,6 +586,20 @@
                 pass
             m.close()
 
+    def test_context_manager(self):
+        with mmap.mmap(-1, 10) as m:
+            self.assertFalse(m.closed)
+        self.assertTrue(m.closed)
+
+    def test_context_manager_exception(self):
+        # Test that the IOError gets passed through
+        with self.assertRaises(Exception) as exc:
+            with mmap.mmap(-1, 10) as m:
+                raise IOError
+        self.assertIsInstance(exc.exception, IOError,
+                              "wrong exception raised in context manager")
+        self.assertTrue(m.closed, "context manager failed")
+
 
 def test_main():
     run_unittest(MmapTests)