mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
Issue #4885: Add weakref support to mmap objects. Patch by Valerie Lambert.
This commit is contained in:
parent
914061ab15
commit
c53204b947
4 changed files with 23 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue