summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fcntl.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-12-05 15:13:03 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-12-05 15:13:03 (GMT)
commit0a956f1aec601a976234011fda075006681bdb82 (patch)
treee0135f3c806b47038f2946ba616af1246924568a /Lib/test/test_fcntl.py
parentac98a4e40730f9d7216f67ce8f2e10cde6055cdb (diff)
downloadcpython-0a956f1aec601a976234011fda075006681bdb82.zip
cpython-0a956f1aec601a976234011fda075006681bdb82.tar.gz
cpython-0a956f1aec601a976234011fda075006681bdb82.tar.bz2
Add simple test for fcntl.flock()
Diffstat (limited to 'Lib/test/test_fcntl.py')
-rw-r--r--Lib/test/test_fcntl.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index c816d97..837fc16 100644
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -115,6 +115,21 @@ class TestFcntl(unittest.TestCase):
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)