| OLD | NEW |
| 1 "Test posix functions" | 1 "Test posix functions" |
| 2 | 2 |
| 3 from test import support | 3 from test import support |
| 4 | 4 |
| 5 # Skip these tests if there is no posix module. | 5 # Skip these tests if there is no posix module. |
| 6 posix = support.import_module('posix') | 6 posix = support.import_module('posix') |
| 7 | 7 |
| 8 import errno | 8 import errno |
| 9 import sys | 9 import sys |
| 10 import time | 10 import time |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 b |= r | 1001 b |= r |
| 1002 self.assertIs(b, l) | 1002 self.assertIs(b, l) |
| 1003 self.assertEqual(l.count(), 3) | 1003 self.assertEqual(l.count(), 3) |
| 1004 | 1004 |
| 1005 def test_rtld_constants(self): | 1005 def test_rtld_constants(self): |
| 1006 # check presence of major RTLD_* constants | 1006 # check presence of major RTLD_* constants |
| 1007 posix.RTLD_LAZY | 1007 posix.RTLD_LAZY |
| 1008 posix.RTLD_NOW | 1008 posix.RTLD_NOW |
| 1009 posix.RTLD_GLOBAL | 1009 posix.RTLD_GLOBAL |
| 1010 posix.RTLD_LOCAL | 1010 posix.RTLD_LOCAL |
| 1011 |
| 1012 @unittest.skipUnless(hasattr(os, 'SEEK_HOLE'), |
| 1013 "test needs an OS that reports file holes") |
| 1014 def test_fs_holes(self) : |
| 1015 # Even if the filesystem doesn't report holes, |
| 1016 # if the OS supports it the SEEK_* constants |
| 1017 # will be defined and will have a consistent |
| 1018 # behaviour: |
| 1019 # os.SEEK_DATA = current position |
| 1020 # os.SEEK_HOLE = end of file position |
| 1021 with open(support.TESTFN, 'r+b') as fp : |
| 1022 fp.write(b"hello") |
| 1023 fp.flush() |
| 1024 size = fp.tell() |
| 1025 fno = fp.fileno() |
| 1026 for i in range(size) : |
| 1027 self.assertEqual(i, os.lseek(fno, i, os.SEEK_DATA)) |
| 1028 self.assertLessEqual(size, os.lseek(fno, i, os.SEEK_HOLE)) |
| 1029 self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_DATA) |
| 1030 self.assertRaises(OSError, os.lseek, fno, size, os.SEEK_HOLE) |
| 1011 | 1031 |
| 1012 class PosixGroupsTester(unittest.TestCase): | 1032 class PosixGroupsTester(unittest.TestCase): |
| 1013 | 1033 |
| 1014 def setUp(self): | 1034 def setUp(self): |
| 1015 if posix.getuid() != 0: | 1035 if posix.getuid() != 0: |
| 1016 raise unittest.SkipTest("not enough privileges") | 1036 raise unittest.SkipTest("not enough privileges") |
| 1017 if not hasattr(posix, 'getgroups'): | 1037 if not hasattr(posix, 'getgroups'): |
| 1018 raise unittest.SkipTest("need posix.getgroups") | 1038 raise unittest.SkipTest("need posix.getgroups") |
| 1019 if sys.platform == 'darwin': | 1039 if sys.platform == 'darwin': |
| 1020 raise unittest.SkipTest("getgroups(2) is broken on OSX") | 1040 raise unittest.SkipTest("getgroups(2) is broken on OSX") |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1045 self.assertListEqual(groups, posix.getgroups()) | 1065 self.assertListEqual(groups, posix.getgroups()) |
| 1046 | 1066 |
| 1047 def test_main(): | 1067 def test_main(): |
| 1048 try: | 1068 try: |
| 1049 support.run_unittest(PosixTester, PosixGroupsTester) | 1069 support.run_unittest(PosixTester, PosixGroupsTester) |
| 1050 finally: | 1070 finally: |
| 1051 support.reap_children() | 1071 support.reap_children() |
| 1052 | 1072 |
| 1053 if __name__ == '__main__': | 1073 if __name__ == '__main__': |
| 1054 test_main() | 1074 test_main() |
| OLD | NEW |