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

Method test_splice

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

Source from the content-addressed store, hash-verified

521 @unittest.skipUnless(hasattr(os, 'splice'), 'test needs os.splice()')
522 @requires_splice_pipe
523 def test_splice(self):
524 TESTFN2 = os_helper.TESTFN + ".3"
525 data = b'0123456789'
526
527 create_file(os_helper.TESTFN, data)
528 self.addCleanup(os_helper.unlink, os_helper.TESTFN)
529
530 in_file = open(os_helper.TESTFN, 'rb')
531 self.addCleanup(in_file.close)
532 in_fd = in_file.fileno()
533
534 read_fd, write_fd = os.pipe()
535 self.addCleanup(lambda: os.close(read_fd))
536 self.addCleanup(lambda: os.close(write_fd))
537
538 try:
539 i = os.splice(in_fd, write_fd, 5)
540 except OSError as e:
541 # Handle the case in which Python was compiled
542 # in a system with the syscall but without support
543 # in the kernel.
544 if e.errno != errno.ENOSYS:
545 raise
546 self.skipTest(e)
547 else:
548 # The number of copied bytes can be less than
549 # the number of bytes originally requested.
550 self.assertIn(i, range(0, 6));
551
552 self.assertEqual(os.read(read_fd, 100), data[:i])
553
554 @unittest.skipUnless(hasattr(os, 'splice'), 'test needs os.splice()')
555 @requires_splice_pipe

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected