MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_copy_file_range

Method test_copy_file_range

Lib/test/test_os.py:438–469  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

436
437 @unittest.skipUnless(hasattr(os, 'copy_file_range'), 'test needs os.copy_file_range()')
438 def test_copy_file_range(self):
439 TESTFN2 = os_helper.TESTFN + ".3"
440 data = b'0123456789'
441
442 create_file(os_helper.TESTFN, data)
443 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
444
445 in_file = open(os_helper.TESTFN, 'rb')
446 self.addCleanup(in_file.close)
447 in_fd = in_file.fileno()
448
449 out_file = open(TESTFN2, 'w+b')
450 self.addCleanup(os_helper.unlink, TESTFN2)
451 self.addCleanup(out_file.close)
452 out_fd = out_file.fileno()
453
454 try:
455 i = os.copy_file_range(in_fd, out_fd, 5)
456 except OSError as e:
457 # Handle the case in which Python was compiled
458 # in a system with the syscall but without support
459 # in the kernel.
460 if e.errno != errno.ENOSYS:
461 raise
462 self.skipTest(e)
463 else:
464 # The number of copied bytes can be less than
465 # the number of bytes originally requested.
466 self.assertIn(i, range(0, 6));
467
468 with open(TESTFN2, 'rb') as in_file:
469 self.assertEqual(in_file.read(), data[:i])
470
471 @unittest.skipUnless(hasattr(os, 'copy_file_range'), 'test needs os.copy_file_range()')
472 def test_copy_file_range_offset(self):

Callers

nothing calls this directly

Calls 8

addCleanupMethod · 0.80
skipTestMethod · 0.80
assertInMethod · 0.80
create_fileFunction · 0.70
openFunction · 0.50
filenoMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected