diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-20 06:22:13 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-20 06:22:13 (GMT) |
commit | 16b2e4f5480bb46a025f9d3a917a923e7f7f59f1 (patch) | |
tree | 63144916d60e4c2cbab4e85fe501822e8cac3773 /Lib | |
parent | cdbe29902e39cc575204ae1ac13505f3a699b8ba (diff) | |
download | cpython-16b2e4f5480bb46a025f9d3a917a923e7f7f59f1.zip cpython-16b2e4f5480bb46a025f9d3a917a923e7f7f59f1.tar.gz cpython-16b2e4f5480bb46a025f9d3a917a923e7f7f59f1.tar.bz2 |
Issue #23842: Added tests for os.major(), os.minor() and os.makedev().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_posix.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 72fdd16..ce8f0b3 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -443,6 +443,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): |