aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_fcntl.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_fcntl.py')
-rw-r--r--Lib/test/test_fcntl.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index df0939151f0..29af99cf162 100644
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -7,8 +7,7 @@ import os
import struct
import sys
import unittest
-from test.test_support import (verbose, TESTFN, unlink, run_unittest,
- import_module)
+from test.support import verbose, TESTFN, unlink, run_unittest, import_module
# Skip test if no fnctl module.
fcntl = import_module('fcntl')
@@ -17,15 +16,12 @@ fcntl = import_module('fcntl')
# TODO - Write tests for flock() and lockf().
def get_lockdata():
- if sys.platform.startswith('atheos'):
- start_len = "qq"
+ try:
+ os.O_LARGEFILE
+ except AttributeError:
+ start_len = "ll"
else:
- try:
- os.O_LARGEFILE
- except AttributeError:
- start_len = "ll"
- else:
- start_len = "qq"
+ start_len = "qq"
if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos'))
or sys.platform == 'darwin'):
@@ -45,12 +41,11 @@ def get_lockdata():
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
- print 'struct.pack: ', repr(lockdata)
+ print('struct.pack: ', repr(lockdata))
return lockdata
lockdata = get_lockdata()
-
class TestFcntl(unittest.TestCase):
def setUp(self):
@@ -63,19 +58,19 @@ class TestFcntl(unittest.TestCase):
def test_fcntl_fileno(self):
# the example from the library docs
- self.f = open(TESTFN, 'w')
+ self.f = open(TESTFN, 'wb')
rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
if verbose:
- print 'Status from fcntl with O_NONBLOCK: ', rv
+ print('Status from fcntl with O_NONBLOCK: ', rv)
if sys.platform not in ['os2emx']:
rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, lockdata)
if verbose:
- print 'String from fcntl with F_SETLKW: ', repr(rv)
+ print('String from fcntl with F_SETLKW: ', repr(rv))
self.f.close()
def test_fcntl_file_descriptor(self):
# again, but pass the file rather than numeric descriptor
- self.f = open(TESTFN, 'w')
+ self.f = open(TESTFN, 'wb')
rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK)
if sys.platform not in ['os2emx']:
rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)