summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2005-06-17 01:14:49 (GMT)
committerSkip Montanaro <skip@pobox.com>2005-06-17 01:14:49 (GMT)
commit98470002672dd10c4b28763f26ed2f2320fac647 (patch)
tree3813482cd6f29366a801f7a7dcc541557c4b392b /Lib/test/test_posix.py
parent2ab0ae6a5431205aeda1142342b4df052f2e4845 (diff)
downloadcpython-98470002672dd10c4b28763f26ed2f2320fac647.zip
cpython-98470002672dd10c4b28763f26ed2f2320fac647.tar.gz
cpython-98470002672dd10c4b28763f26ed2f2320fac647.tar.bz2
Add tests for posix O_SHLOCK & O_EXLOCK. Missed checking this in with
posixmodule.c 2.335. Really should be considered part of patch #1103951.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 24e5b1c..1ccc62b 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -94,6 +94,37 @@ class PosixTester(unittest.TestCase):
self.fdopen_helper('r')
self.fdopen_helper('r', 100)
+ def test_osexlock(self):
+ if hasattr(posix, "O_EXLOCK"):
+ fd = os.open(test_support.TESTFN,
+ os.O_WRONLY|os.O_EXLOCK|os.O_CREAT)
+ self.assertRaises(OSError, os.open, test_support.TESTFN,
+ os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
+ os.close(fd)
+
+ if hasattr(posix, "O_SHLOCK"):
+ fd = os.open(test_support.TESTFN,
+ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+ self.assertRaises(OSError, os.open, test_support.TESTFN,
+ os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
+ os.close(fd)
+
+ def test_osshlock(self):
+ if hasattr(posix, "O_SHLOCK"):
+ fd1 = os.open(test_support.TESTFN,
+ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+ fd2 = os.open(test_support.TESTFN,
+ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+ os.close(fd2)
+ os.close(fd1)
+
+ if hasattr(posix, "O_EXLOCK"):
+ fd = os.open(test_support.TESTFN,
+ os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
+ self.assertRaises(OSError, os.open, test_support.TESTFN,
+ os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK)
+ os.close(fd)
+
def test_fstat(self):
if hasattr(posix, 'fstat'):
fp = open(test_support.TESTFN)