[Python-checkins] cpython: Add simple test for fcntl.flock()
christian.heimes
python-checkins at python.org
Thu Dec 5 16:13:38 CET 2013
http://hg.python.org/cpython/rev/6f8a5458108d
changeset: 87780:6f8a5458108d
user: Christian Heimes <christian at cheimes.de>
date: Thu Dec 05 16:13:03 2013 +0100
summary:
Add simple test for fcntl.flock()
files:
Lib/test/test_fcntl.py | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -115,6 +115,21 @@
finally:
os.close(fd)
+ def test_flock(self):
+ self.f = open(TESTFN, 'wb')
+ fileno = self.f.fileno()
+ fcntl.flock(fileno, fcntl.LOCK_SH)
+ fcntl.flock(fileno, fcntl.LOCK_UN)
+ fcntl.flock(self.f, fcntl.LOCK_SH | fcntl.LOCK_NB)
+ fcntl.flock(self.f, fcntl.LOCK_UN)
+ fcntl.flock(fileno, fcntl.LOCK_EX)
+ fcntl.flock(fileno, fcntl.LOCK_UN)
+
+ self.assertRaises(ValueError, fcntl.flock, -1, fcntl.LOCK_SH)
+ self.assertRaises(TypeError, fcntl.flock, 'spam', fcntl.LOCK_SH)
+ self.assertRaises(OverflowError, fcntl.flock, _testcapi.INT_MAX+1,
+ fcntl.LOCK_SH)
+
def test_main():
run_unittest(TestFcntl)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list