MCPcopy Create free account
hub / github.com/python/cpython / test_open_dir_fd

Method test_open_dir_fd

Lib/test/test_os/test_posix.py:1814–1824  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1812
1813 @unittest.skipUnless(os.open in os.supports_dir_fd, "test needs dir_fd support in os.open()")
1814 def test_open_dir_fd(self):
1815 with self.prepare() as (dir_fd, name, fullname):
1816 with open(fullname, 'wb') as outfile:
1817 outfile.write(b"testline\n")
1818 self.addCleanup(posix.unlink, fullname)
1819 fd = posix.open(name, posix.O_RDONLY, dir_fd=dir_fd)
1820 try:
1821 res = posix.read(fd, 9)
1822 self.assertEqual(b"testline\n", res)
1823 finally:
1824 posix.close(fd)
1825
1826 @unittest.skipUnless(hasattr(os, 'readlink') and (os.readlink in os.supports_dir_fd),
1827 "test needs dir_fd support in os.readlink()")

Callers

nothing calls this directly

Calls 8

prepareMethod · 0.95
addCleanupMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
openMethod · 0.45
readMethod · 0.45
assertEqualMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected