MCPcopy Index your code
hub / github.com/python/cpython / test_flush

Method test_flush

Lib/test/test_free_threading/test_mmap.py:256–276  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

254 @unittest.skipUnless(os.name == "posix", "requires Posix")
255 @unittest.skipUnless(hasattr(mmap.mmap, "resize"), "requires mmap.resize")
256 def test_flush(self):
257 mmap_filename = "test_mmap_file"
258 resize_to = 1024
259
260 def resize_and_flush(mm_obj):
261 mm_obj.resize(resize_to)
262 mm_obj.flush()
263
264 with tempfile.TemporaryDirectory() as tmpdirname:
265 file_path = f"{tmpdirname}/{mmap_filename}"
266 with open(file_path, "wb+") as file:
267 file.write(b"CPython")
268 file.flush()
269 with mmap.mmap(file.fileno(), 1) as mm_obj:
270 run_concurrently(
271 worker_func=resize_and_flush,
272 args=(mm_obj,),
273 nthreads=NTHREADS,
274 )
275
276 self.assertEqual(os.path.getsize(file_path), resize_to)
277
278 def test_mmap_export_as_memoryview(self):
279 """

Callers

nothing calls this directly

Calls 6

run_concurrentlyFunction · 0.90
openFunction · 0.50
writeMethod · 0.45
flushMethod · 0.45
filenoMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected