• Home
  • Raw
  • Download

Lines Matching refs:posix

6 posix = test_support.import_module('posix')  variable
51 posix_func = getattr(posix, name, None)
56 @unittest.skipUnless(hasattr(posix, 'getresuid'),
59 user_ids = posix.getresuid()
64 @unittest.skipUnless(hasattr(posix, 'getresgid'),
67 group_ids = posix.getresgid()
72 @unittest.skipUnless(hasattr(posix, 'setresuid'),
75 current_user_ids = posix.getresuid()
76 self.assertIsNone(posix.setresuid(*current_user_ids))
78 self.assertIsNone(posix.setresuid(-1, -1, -1))
80 @unittest.skipUnless(hasattr(posix, 'setresuid'),
84 current_user_ids = posix.getresuid()
87 self.assertRaises(OSError, posix.setresuid, *new_user_ids)
89 @unittest.skipUnless(hasattr(posix, 'setresgid'),
92 current_group_ids = posix.getresgid()
93 self.assertIsNone(posix.setresgid(*current_group_ids))
95 self.assertIsNone(posix.setresgid(-1, -1, -1))
97 @unittest.skipUnless(hasattr(posix, 'setresgid'),
101 current_group_ids = posix.getresgid()
104 self.assertRaises(OSError, posix.setresgid, *new_group_ids)
106 @unittest.skipUnless(hasattr(posix, 'initgroups'),
111 self.assertRaises(TypeError, posix.initgroups)
112 self.assertRaises(TypeError, posix.initgroups, None)
113 self.assertRaises(TypeError, posix.initgroups, 3, "foo")
114 self.assertRaises(TypeError, posix.initgroups, "foo", 3, object())
120 name = pwd.getpwuid(posix.getuid()).pw_name
125 posix.initgroups(name, 13)
131 @unittest.skipUnless(hasattr(posix, 'statvfs'),
134 self.assertTrue(posix.statvfs(os.curdir))
136 @unittest.skipUnless(hasattr(posix, 'fstatvfs'),
141 self.assertTrue(posix.fstatvfs(fp.fileno()))
145 @unittest.skipUnless(hasattr(posix, 'ftruncate'),
153 posix.ftruncate(fp.fileno(), 0)
157 @unittest.skipUnless(hasattr(posix, 'dup'),
162 fd = posix.dup(fp.fileno())
168 @unittest.skipUnless(hasattr(posix, 'confstr'),
171 self.assertRaises(ValueError, posix.confstr, "CS_garbage")
172 self.assertEqual(len(posix.confstr("CS_PATH")) > 0, True)
174 @unittest.skipUnless(hasattr(posix, 'dup2'),
180 posix.dup2(fp1.fileno(), fp2.fileno())
187 fp2 = posix.fdopen(fd, *args)
190 @unittest.skipUnless(hasattr(posix, 'fdopen'),
197 @unittest.skipUnless(hasattr(posix, 'fdopen'),
210 @unittest.skipUnless(hasattr(posix, 'fdopen') and
215 self.assertRaises(OSError, posix.fdopen, fd, 'w')
218 @unittest.skipUnless(hasattr(posix, 'O_EXLOCK'),
227 if hasattr(posix, "O_SHLOCK"):
234 @unittest.skipUnless(hasattr(posix, 'O_SHLOCK'),
244 if hasattr(posix, "O_EXLOCK"):
251 @unittest.skipUnless(hasattr(posix, 'fstat'),
256 self.assertTrue(posix.fstat(fp.fileno()))
260 @unittest.skipUnless(hasattr(posix, 'stat'),
263 self.assertTrue(posix.stat(test_support.TESTFN))
265 @unittest.skipUnless(hasattr(posix, 'stat'), 'test needs posix.stat()')
266 @unittest.skipUnless(hasattr(posix, 'makedev'), 'test needs posix.makedev()')
268 st = posix.stat(test_support.TESTFN)
273 major = posix.major(dev)
276 self.assertEqual(posix.major(int(dev)), major)
277 self.assertEqual(posix.major(long(dev)), major)
278 self.assertRaises(TypeError, posix.major, float(dev))
279 self.assertRaises(TypeError, posix.major)
280 self.assertRaises((ValueError, OverflowError), posix.major, -1)
282 minor = posix.minor(dev)
285 self.assertEqual(posix.minor(int(dev)), minor)
286 self.assertEqual(posix.minor(long(dev)), minor)
287 self.assertRaises(TypeError, posix.minor, float(dev))
288 self.assertRaises(TypeError, posix.minor)
289 self.assertRaises((ValueError, OverflowError), posix.minor, -1)
295 self.assertEqual(posix.makedev(major, minor), dev)
296 self.assertEqual(posix.makedev(int(major), int(minor)), dev)
297 self.assertEqual(posix.makedev(long(major), long(minor)), dev)
298 self.assertRaises(TypeError, posix.makedev, float(major), minor)
299 self.assertRaises(TypeError, posix.makedev, major, float(minor))
300 self.assertRaises(TypeError, posix.makedev, major)
301 self.assertRaises(TypeError, posix.makedev)
362 @unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
366 self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1)
370 self._test_all_chown_common(posix.chown, test_support.TESTFN,
371 getattr(posix, 'stat', None))
373 @unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
381 self._test_all_chown_common(posix.fchown, fd,
382 getattr(posix, 'fstat', None))
386 @unittest.skipUnless(hasattr(posix, 'lchown'), "test needs os.lchown()")
391 self._test_all_chown_common(posix.lchown, test_support.TESTFN,
392 getattr(posix, 'lstat', None))
394 @unittest.skipUnless(hasattr(posix, 'chdir'), 'test needs posix.chdir()')
396 posix.chdir(os.curdir)
397 self.assertRaises(OSError, posix.chdir, test_support.TESTFN)
399 @unittest.skipUnless(hasattr(posix, 'lsdir'), 'test needs posix.lsdir()')
401 self.assertIn(test_support.TESTFN, posix.lsdir(os.curdir))
403 @unittest.skipUnless(hasattr(posix, 'access'), 'test needs posix.access()')
405 self.assertTrue(posix.access(test_support.TESTFN, os.R_OK))
407 @unittest.skipUnless(hasattr(posix, 'umask'), 'test needs posix.umask()')
409 old_mask = posix.umask(0)
411 posix.umask(old_mask)
413 @unittest.skipUnless(hasattr(posix, 'strerror'),
416 self.assertTrue(posix.strerror(0))
418 @unittest.skipUnless(hasattr(posix, 'pipe'), 'test needs posix.pipe()')
420 reader, writer = posix.pipe()
424 @unittest.skipUnless(hasattr(posix, 'tempnam'),
429 self.assertTrue(posix.tempnam())
430 self.assertTrue(posix.tempnam(os.curdir))
431 self.assertTrue(posix.tempnam(os.curdir, 'blah'))
433 @unittest.skipUnless(hasattr(posix, 'tmpfile'),
438 fp = posix.tmpfile()
441 @unittest.skipUnless(hasattr(posix, 'utime'), 'test needs posix.utime()')
444 posix.utime(test_support.TESTFN, None)
445 self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None))
446 self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None))
447 self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now))
448 posix.utime(test_support.TESTFN, (int(now), int(now)))
449 posix.utime(test_support.TESTFN, (now, now))
472 posix.chflags(target_file, st.st_flags)
474 @unittest.skipUnless(hasattr(posix, 'chflags'), 'test needs os.chflags()')
476 self._test_chflags_regular_file(posix.chflags, test_support.TESTFN)
478 @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
480 self._test_chflags_regular_file(posix.lchflags, test_support.TESTFN)
482 @unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
494 posix.lchflags(_DUMMY_SYMLINK,
510 posix.lchflags(_DUMMY_SYMLINK, dummy_symlink_st.st_flags)
521 @unittest.skipUnless(hasattr(posix, 'getcwd'),
592 set(posix.getgroups() + [posix.getegid()]))
639 if posix.getuid() != 0:
641 if not hasattr(posix, 'getgroups'):
645 self.saved_groups = posix.getgroups()
648 if hasattr(posix, 'setgroups'):
649 posix.setgroups(self.saved_groups)
650 elif hasattr(posix, 'initgroups'):
651 name = pwd.getpwuid(posix.getuid()).pw_name
652 posix.initgroups(name, self.saved_groups[0])
654 @unittest.skipUnless(hasattr(posix, 'initgroups'),
660 name = pwd.getpwuid(posix.getuid()).pw_name
661 posix.initgroups(name, g)
662 self.assertIn(g, posix.getgroups())
664 @unittest.skipUnless(hasattr(posix, 'setgroups'),
668 posix.setgroups(groups)
669 self.assertListEqual(groups, posix.getgroups())