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

Delta Between Two Patch Sets: Lib/test/test_posix.py

Issue 10812: Add some posix functions
Left Patch Set: Created 2 years, 2 months ago
Right Patch Set: Created 2 years, 2 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 posix.sethostid(2464787) 165 posix.sethostid(2464787)
166 except OSError as e: 166 except OSError as e:
167 if sys.platform.startswith("freebsd"): 167 if sys.platform.startswith("freebsd"):
168 self.assertEqual(e.errno, errno.EPERM) 168 self.assertEqual(e.errno, errno.EPERM)
169 else: 169 else:
170 self.assertEqual(e.errno, errno.EACCES) 170 self.assertEqual(e.errno, errno.EACCES)
171 else: 171 else:
172 # running test as root! 172 # running test as root!
173 self.assertEqual(os.gethostid(), 2464787) 173 self.assertEqual(os.gethostid(), 2464787)
174 posix.sethostid(hid) 174 posix.sethostid(hid)
175
176 @unittest.skipUnless(hasattr(posix, 'gethostname'), "test needs posix.gethos tname()")
177 def test_gethostname(self):
178 self.assertTrue(isinstance(posix.gethostname(), str))
179
180 @unittest.skipUnless(hasattr(posix, 'sethostname'), "test needs posix.sethos tname()")
181 @unittest.skipUnless(hasattr(posix, 'gethostname'), "test needs posix.gethos tname()")
182 def test_sethostname(self):
183 oldhn = posix.gethostname()
184 try:
185 posix.sethostname('new')
186 except OSError as e:
187 self.assertEqual(e.errno, errno.EPERM)
188 else:
189 # running test as root!
190 self.assertEqual(socket.gethostname(), 'new')
191 posix.sethostname(oldhn)
192 175
193 @unittest.skipUnless(hasattr(posix, 'waitid'), "test needs posix.waitid()") 176 @unittest.skipUnless(hasattr(posix, 'waitid'), "test needs posix.waitid()")
194 @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()") 177 @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
195 def test_waitid(self): 178 def test_waitid(self):
196 pid = os.fork() 179 pid = os.fork()
197 if pid == 0: 180 if pid == 0:
198 os.chdir(os.path.split(sys.executable)[0]) 181 os.chdir(os.path.split(sys.executable)[0])
199 posix.execve(sys.executable, [sys.executable, '-c', 'pass'], os.envi ron) 182 posix.execve(sys.executable, [sys.executable, '-c', 'pass'], os.envi ron)
200 else: 183 else:
201 res = posix.waitid(posix.P_PID, pid, posix.WEXITED) 184 res = posix.waitid(posix.P_PID, pid, posix.WEXITED)
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 for groups in [[0], list(range(16))]: 589 for groups in [[0], list(range(16))]:
607 posix.setgroups(groups) 590 posix.setgroups(groups)
608 self.assertListEqual(groups, posix.getgroups()) 591 self.assertListEqual(groups, posix.getgroups())
609 592
610 593
611 def test_main(): 594 def test_main():
612 support.run_unittest(PosixTester, PosixGroupsTester) 595 support.run_unittest(PosixTester, PosixGroupsTester)
613 596
614 if __name__ == '__main__': 597 if __name__ == '__main__':
615 test_main() 598 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7