diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index f37f2de11c1..d49cd92c77d 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -442,6 +442,36 @@ class PosixTester(unittest.TestCase): else: self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode)) + @unittest.skipUnless(hasattr(posix, 'stat'), 'test needs posix.stat()') + @unittest.skipUnless(hasattr(posix, 'makedev'), 'test needs posix.makedev()') + def test_makedev(self): + st = posix.stat(support.TESTFN) + dev = st.st_dev + self.assertIsInstance(dev, int) + self.assertGreaterEqual(dev, 0) + + major = posix.major(dev) + self.assertIsInstance(major, int) + self.assertGreaterEqual(major, 0) + self.assertEqual(posix.major(dev), major) + self.assertRaises(TypeError, posix.major, float(dev)) + self.assertRaises(TypeError, posix.major) + self.assertRaises((ValueError, OverflowError), posix.major, -1) + + minor = posix.minor(dev) + self.assertIsInstance(minor, int) + self.assertGreaterEqual(minor, 0) + self.assertEqual(posix.minor(dev), minor) + self.assertRaises(TypeError, posix.minor, float(dev)) + self.assertRaises(TypeError, posix.minor) + self.assertRaises((ValueError, OverflowError), posix.minor, -1) + + self.assertEqual(posix.makedev(major, minor), dev) + self.assertRaises(TypeError, posix.makedev, float(major), minor) + self.assertRaises(TypeError, posix.makedev, major, float(minor)) + self.assertRaises(TypeError, posix.makedev, major) + self.assertRaises(TypeError, posix.makedev) + def _test_all_chown_common(self, chown_func, first_param, stat_func): """Common code for chown, fchown and lchown tests.""" def check_stat(uid, gid):