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