MCPcopy Index your code
hub / github.com/numpy/numpy / test_mmap_close

Method test_mmap_close

numpy/_core/tests/test_multiarray.py:6615–6627  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6613 assert_array_equal(np.frombuffer(b''), np.array([]))
6614
6615 def test_mmap_close(self):
6616 # The old buffer protocol was not safe for some things that the new
6617 # one is. But `frombuffer` always used the old one for a long time.
6618 # Checks that it is safe with the new one (using memoryviews)
6619 with tempfile.TemporaryFile(mode='wb') as tmp:
6620 tmp.write(b"asdf")
6621 tmp.flush()
6622 mm = mmap.mmap(tmp.fileno(), 0)
6623 arr = np.frombuffer(mm, dtype=np.uint8)
6624 with pytest.raises(BufferError):
6625 mm.close() # cannot close while array uses the buffer
6626 del arr
6627 mm.close()
6628
6629class TestFlat:
6630 def _create_arrays(self):

Callers

nothing calls this directly

Calls 3

writeMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected