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

Method test_stat_dir_fd

Lib/test/test_posix.py:1636–1660  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1634
1635 @unittest.skipUnless(os.stat in os.supports_dir_fd, "test needs dir_fd support in os.stat()")
1636 def test_stat_dir_fd(self):
1637 with self.prepare() as (dir_fd, name, fullname):
1638 with open(fullname, 'w') as outfile:
1639 outfile.write("testline\n")
1640 self.addCleanup(posix.unlink, fullname)
1641
1642 s1 = posix.stat(fullname)
1643 s2 = posix.stat(name, dir_fd=dir_fd)
1644 self.assertEqual(s1, s2)
1645 s2 = posix.stat(fullname, dir_fd=None)
1646 self.assertEqual(s1, s2)
1647
1648 self.assertRaisesRegex(TypeError, 'should be integer or None, not',
1649 posix.stat, name, dir_fd=posix.getcwd())
1650 self.assertRaisesRegex(TypeError, 'should be integer or None, not',
1651 posix.stat, name, dir_fd=float(dir_fd))
1652 self.assertRaises(OverflowError,
1653 posix.stat, name, dir_fd=10**20)
1654
1655 for fd in False, True:
1656 with self.assertWarnsRegex(RuntimeWarning,
1657 'bool is used as a file descriptor') as cm:
1658 with self.assertRaises(OSError):
1659 posix.stat('nonexisting', dir_fd=fd)
1660 self.assertEqual(cm.filename, __file__)
1661
1662 @unittest.skipUnless(os.utime in os.supports_dir_fd, "test needs dir_fd support in os.utime()")
1663 def test_utime_dir_fd(self):

Callers

nothing calls this directly

Calls 9

prepareMethod · 0.95
addCleanupMethod · 0.80
assertRaisesRegexMethod · 0.80
assertWarnsRegexMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
statMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected