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

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

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 10 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_faulthandler.py ('k') | Lib/test/test_ftplib.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 program for the fcntl C module. 1 """Test program for the fcntl C module.
2 2
3 OS/2+EMX doesn't support the file locking operations. 3 OS/2+EMX doesn't support the file locking operations.
4 4
5 """ 5 """
6 import os 6 import os
7 import struct 7 import struct
8 import sys 8 import sys
9 import unittest 9 import unittest
10 from test.support import verbose, TESTFN, unlink, run_unittest, import_module 10 from test.support import verbose, TESTFN, unlink, run_unittest, import_module
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 def setUp(self): 55 def setUp(self):
56 self.f = None 56 self.f = None
57 57
58 def tearDown(self): 58 def tearDown(self):
59 if self.f and not self.f.closed: 59 if self.f and not self.f.closed:
60 self.f.close() 60 self.f.close()
61 unlink(TESTFN) 61 unlink(TESTFN)
62 62
63 def test_fcntl_fileno(self): 63 def test_fcntl_fileno(self):
64 # the example from the library docs 64 # the example from the library docs
65 self.f = open(TESTFN, 'wb') 65 self.f = open(TESTFN, 'w')
66 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) 66 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
67 if verbose: 67 if verbose:
68 print('Status from fcntl with O_NONBLOCK: ', rv) 68 print('Status from fcntl with O_NONBLOCK: ', rv)
69 if sys.platform not in ['os2emx']: 69 if sys.platform not in ['os2emx']:
70 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, lockdata) 70 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, lockdata)
71 if verbose: 71 if verbose:
72 print('String from fcntl with F_SETLKW: ', repr(rv)) 72 print('String from fcntl with F_SETLKW: ', repr(rv))
73 self.f.close() 73 self.f.close()
74 74
75 def test_fcntl_file_descriptor(self): 75 def test_fcntl_file_descriptor(self):
76 # again, but pass the file rather than numeric descriptor 76 # again, but pass the file rather than numeric descriptor
77 self.f = open(TESTFN, 'wb') 77 self.f = open(TESTFN, 'w')
78 rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK) 78 rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK)
79 if sys.platform not in ['os2emx']: 79 if sys.platform not in ['os2emx']:
80 rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) 80 rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)
81 self.f.close() 81 self.f.close()
82 82
83 def test_fcntl_64_bit(self): 83 def test_fcntl_64_bit(self):
84 # Issue #1309352: fcntl shouldn't fail when the third arg fits in a 84 # Issue #1309352: fcntl shouldn't fail when the third arg fits in a
85 # C 'long' but not in a C 'int'. 85 # C 'long' but not in a C 'int'.
86 try: 86 try:
87 cmd = fcntl.F_NOTIFY 87 cmd = fcntl.F_NOTIFY
88 # This flag is larger than 2**31 in 64-bit builds 88 # This flag is larger than 2**31 in 64-bit builds
89 flags = fcntl.DN_MULTISHOT 89 flags = fcntl.DN_MULTISHOT
90 except AttributeError: 90 except AttributeError:
91 self.skipTest("F_NOTIFY or DN_MULTISHOT unavailable") 91 self.skipTest("F_NOTIFY or DN_MULTISHOT unavailable")
92 fd = os.open(os.path.dirname(os.path.abspath(TESTFN)), os.O_RDONLY) 92 fd = os.open(os.path.dirname(os.path.abspath(TESTFN)), os.O_RDONLY)
93 try: 93 try:
94 fcntl.fcntl(fd, cmd, flags) 94 fcntl.fcntl(fd, cmd, flags)
95 finally: 95 finally:
96 os.close(fd) 96 os.close(fd)
97 97
98 98
99 def test_main(): 99 def test_main():
100 run_unittest(TestFcntl) 100 run_unittest(TestFcntl)
101 101
102 if __name__ == '__main__': 102 if __name__ == '__main__':
103 test_main() 103 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_faulthandler.py ('k') | Lib/test/test_ftplib.py » ('j') | no next file with comments »

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