diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-05 21:17:30 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-05 21:17:30 (GMT) |
commit | c53204b9477a2e28b6b366fd271f61c73b805cee (patch) | |
tree | a58457d2a8f68a43ae5ce33adc3da41944b7a547 /Lib | |
parent | 914061ab151a7dd25e9b05091eabbfd2690ee438 (diff) | |
download | cpython-c53204b9477a2e28b6b366fd271f61c73b805cee.zip cpython-c53204b9477a2e28b6b366fd271f61c73b805cee.tar.gz cpython-c53204b9477a2e28b6b366fd271f61c73b805cee.tar.bz2 |
Issue #4885: Add weakref support to mmap objects. Patch by Valerie Lambert.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_mmap.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 505ffba..b1cc973 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1,11 +1,12 @@ from test.support import (TESTFN, run_unittest, import_module, unlink, - requires, _2G, _4G) + requires, _2G, _4G, gc_collect) import unittest import os import re import itertools import socket import sys +import weakref # Skip test if we can't import mmap. mmap = import_module('mmap') @@ -692,6 +693,15 @@ class MmapTests(unittest.TestCase): "wrong exception raised in context manager") self.assertTrue(m.closed, "context manager failed") + def test_weakref(self): + # Check mmap objects are weakrefable + mm = mmap.mmap(-1, 16) + wr = weakref.ref(mm) + self.assertIs(wr(), mm) + del mm + gc_collect() + self.assertIs(wr(), None) + class LargeMmapTests(unittest.TestCase): def setUp(self): |