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

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

Issue 23001: Accept mutable bytes-like objects
Patch Set: Created 4 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
OLDNEW
1 """Test program for the fcntl C module. 1 """Test program for the fcntl C module.
2 """ 2 """
3 import platform 3 import platform
4 import os 4 import os
5 import struct 5 import struct
6 import sys 6 import sys
7 import unittest 7 import unittest
8 from test.support import (verbose, TESTFN, unlink, run_unittest, import_module, 8 from test.support import (verbose, TESTFN, unlink, run_unittest, import_module,
9 cpython_only) 9 cpython_only)
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 def test_fcntl_fileno(self): 64 def test_fcntl_fileno(self):
65 # the example from the library docs 65 # the example from the library docs
66 self.f = open(TESTFN, 'wb') 66 self.f = open(TESTFN, 'wb')
67 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) 67 rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
68 if verbose: 68 if verbose:
69 print('Status from fcntl with O_NONBLOCK: ', rv) 69 print('Status from fcntl with O_NONBLOCK: ', rv)
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 fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, bytearray(lockdata))
73 self.f.close() 74 self.f.close()
74 75
75 def test_fcntl_file_descriptor(self): 76 def test_fcntl_file_descriptor(self):
76 # again, but pass the file rather than numeric descriptor 77 # again, but pass the file rather than numeric descriptor
77 self.f = open(TESTFN, 'wb') 78 self.f = open(TESTFN, 'wb')
78 rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK) 79 rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK)
79 if verbose: 80 if verbose:
80 print('Status from fcntl with O_NONBLOCK: ', rv) 81 print('Status from fcntl with O_NONBLOCK: ', rv)
81 rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata) 82 rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)
82 if verbose: 83 if verbose:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 import _testcapi 144 import _testcapi
144 self.assertRaises(OverflowError, fcntl.flock, _testcapi.INT_MAX+1, 145 self.assertRaises(OverflowError, fcntl.flock, _testcapi.INT_MAX+1,
145 fcntl.LOCK_SH) 146 fcntl.LOCK_SH)
146 147
147 148
148 def test_main(): 149 def test_main():
149 run_unittest(TestFcntl) 150 run_unittest(TestFcntl)
150 151
151 if __name__ == '__main__': 152 if __name__ == '__main__':
152 test_main() 153 test_main()
OLDNEW

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