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

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

Issue 12196: add pipe2() to the os module
Patch Set: Created 1 year, 11 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 | « Doc/library/os.rst ('k') | Modules/posixmodule.c » ('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
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 reader, writer = posix.pipe() 474 reader, writer = posix.pipe()
475 os.close(reader) 475 os.close(reader)
476 os.close(writer) 476 os.close(writer)
477 477
478 @unittest.skipUnless(hasattr(os, 'pipe2'), "test needs os.pipe2()") 478 @unittest.skipUnless(hasattr(os, 'pipe2'), "test needs os.pipe2()")
479 @support.requires_linux_version(2, 6, 27) 479 @support.requires_linux_version(2, 6, 27)
480 def test_pipe2(self): 480 def test_pipe2(self):
481 self.assertRaises(TypeError, os.pipe2, 'DEADBEEF') 481 self.assertRaises(TypeError, os.pipe2, 'DEADBEEF')
482 self.assertRaises(TypeError, os.pipe2, 0, 0) 482 self.assertRaises(TypeError, os.pipe2, 0, 0)
483 483
484 # try calling without flag, like os.pipe() 484 # try calling with flags = 0, like os.pipe()
485 r, w = os.pipe2() 485 r, w = os.pipe2(0)
486 os.close(r) 486 os.close(r)
487 os.close(w) 487 os.close(w)
488 488
489 # test flags 489 # test flags
490 r, w = os.pipe2(os.O_CLOEXEC|os.O_NONBLOCK) 490 r, w = os.pipe2(os.O_CLOEXEC|os.O_NONBLOCK)
491 self.addCleanup(os.close, r) 491 self.addCleanup(os.close, r)
492 self.addCleanup(os.close, w) 492 self.addCleanup(os.close, w)
493 self.assertTrue(fcntl.fcntl(r, fcntl.F_GETFD) & fcntl.FD_CLOEXEC) 493 self.assertTrue(fcntl.fcntl(r, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
494 self.assertTrue(fcntl.fcntl(w, fcntl.F_GETFD) & fcntl.FD_CLOEXEC) 494 self.assertTrue(fcntl.fcntl(w, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
495 # try reading from an empty pipe: this should fail, not block 495 # try reading from an empty pipe: this should fail, not block
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 814
815 815
816 def test_main(): 816 def test_main():
817 try: 817 try:
818 support.run_unittest(PosixTester, PosixGroupsTester) 818 support.run_unittest(PosixTester, PosixGroupsTester)
819 finally: 819 finally:
820 support.reap_children() 820 support.reap_children()
821 821
822 if __name__ == '__main__': 822 if __name__ == '__main__':
823 test_main() 823 test_main()
OLDNEW
« no previous file with comments | « Doc/library/os.rst ('k') | Modules/posixmodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7