Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(160912)

Side by Side Diff: Lib/test/test_posix.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_popen.py ('k') | Lib/test/test_pty.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 import os 11 import os
12 import platform 12 import platform
13 import pwd 13 import pwd
14 import shutil
15 import stat 14 import stat
15 import subprocess
16 import tempfile 16 import tempfile
17 import unittest 17 import unittest
18 import warnings 18 import warnings
19 19
20 _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(), 20 _DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
21 support.TESTFN + '-dummy-symlink') 21 support.TESTFN + '-dummy-symlink')
22 22
23 class PosixTester(unittest.TestCase): 23 class PosixTester(unittest.TestCase):
24 24
25 def setUp(self): 25 def setUp(self):
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 # HP-UX and Solaris can allow a non-root user to chown() to root 522 # HP-UX and Solaris can allow a non-root user to chown() to root
523 # (issue #5113) 523 # (issue #5113)
524 raise unittest.SkipTest("Skipping because of non-standard chown() " 524 raise unittest.SkipTest("Skipping because of non-standard chown() "
525 "behavior") 525 "behavior")
526 else: 526 else:
527 # non-root cannot chown to root, raises OSError 527 # non-root cannot chown to root, raises OSError
528 self.assertRaises(OSError, chown_func, first_param, 0, 0) 528 self.assertRaises(OSError, chown_func, first_param, 0, 0)
529 check_stat(uid, gid) 529 check_stat(uid, gid)
530 self.assertRaises(OSError, chown_func, first_param, 0, -1) 530 self.assertRaises(OSError, chown_func, first_param, 0, -1)
531 check_stat(uid, gid) 531 check_stat(uid, gid)
532 if 0 not in os.getgroups(): 532 if hasattr(os, 'getgroups'):
533 self.assertRaises(OSError, chown_func, first_param, -1, 0) 533 if 0 not in os.getgroups():
534 check_stat(uid, gid) 534 self.assertRaises(OSError, chown_func, first_param, -1, 0)
535 check_stat(uid, gid)
535 # test illegal types 536 # test illegal types
536 for t in str, float: 537 for t in str, float:
537 self.assertRaises(TypeError, chown_func, first_param, t(uid), gid) 538 self.assertRaises(TypeError, chown_func, first_param, t(uid), gid)
538 check_stat(uid, gid) 539 check_stat(uid, gid)
539 self.assertRaises(TypeError, chown_func, first_param, uid, t(gid)) 540 self.assertRaises(TypeError, chown_func, first_param, uid, t(gid))
540 check_stat(uid, gid) 541 check_stat(uid, gid)
541 542
542 @unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()") 543 @unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
543 def test_chown(self): 544 def test_chown(self):
544 # raise an OSError if the file does not exist 545 # raise an OSError if the file does not exist
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 @unittest.skipUnless(hasattr(posix, 'getgrouplist'), "test needs posix.getgr ouplist()") 787 @unittest.skipUnless(hasattr(posix, 'getgrouplist'), "test needs posix.getgr ouplist()")
787 @unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()") 788 @unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()")
788 @unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()") 789 @unittest.skipUnless(hasattr(os, 'getuid'), "test needs os.getuid()")
789 def test_getgrouplist(self): 790 def test_getgrouplist(self):
790 user = pwd.getpwuid(os.getuid())[0] 791 user = pwd.getpwuid(os.getuid())[0]
791 group = pwd.getpwuid(os.getuid())[3] 792 group = pwd.getpwuid(os.getuid())[3]
792 self.assertIn(group, posix.getgrouplist(user, group)) 793 self.assertIn(group, posix.getgrouplist(user, group))
793 794
794 795
795 @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()") 796 @unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
797 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
796 def test_getgroups(self): 798 def test_getgroups(self):
797 with os.popen('id -G 2>/dev/null') as idg: 799 with os.popen('id -G 2>/dev/null') as idg:
798 groups = idg.read().strip() 800 groups = idg.read().strip()
799 ret = idg.close() 801 ret = idg.close()
800 802
801 if ret is not None or not groups: 803 if ret is not None or not groups:
802 raise unittest.SkipTest("need working 'id -G'") 804 raise unittest.SkipTest("need working 'id -G'")
803 805
804 # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups() 806 # Issues 16698: OS X ABIs prior to 10.6 have limits on getgroups()
805 if sys.platform == 'darwin': 807 if sys.platform == 'darwin':
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 self.assertListEqual(groups, posix.getgroups()) 1250 self.assertListEqual(groups, posix.getgroups())
1249 1251
1250 def test_main(): 1252 def test_main():
1251 try: 1253 try:
1252 support.run_unittest(PosixTester, PosixGroupsTester) 1254 support.run_unittest(PosixTester, PosixGroupsTester)
1253 finally: 1255 finally:
1254 support.reap_children() 1256 support.reap_children()
1255 1257
1256 if __name__ == '__main__': 1258 if __name__ == '__main__':
1257 test_main() 1259 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_popen.py ('k') | Lib/test/test_pty.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+