diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-12-10 21:05:57 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-12-10 21:05:57 +0100 |
commit | 54844a90b97fd7854e53a9aec85bf60564362a02 (patch) | |
tree | d91b8c7e3a7783edb6106753bb593ba567d4bd99 /test/git/test_utils.py | |
parent | a97d21936200f1221d8ddd89202042faed1b9bcb (diff) | |
download | gitpython-54844a90b97fd7854e53a9aec85bf60564362a02.tar.gz |
index: TempFileMover now handles the case that the file to move does not exist more gracefully
Added BlockingLockFile which may be used to wait for the lock according to some criteria
Diffstat (limited to 'test/git/test_utils.py')
-rw-r--r-- | test/git/test_utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/git/test_utils.py b/test/git/test_utils.py index 69a9297d..ade2bffa 100644 --- a/test/git/test_utils.py +++ b/test/git/test_utils.py @@ -11,6 +11,7 @@ from test.testlib import * from git.utils import * from git import * from git.cmd import dashify +import time class TestUtils(TestCase): @@ -53,6 +54,19 @@ class TestUtils(TestCase): lock_file._obtain_lock_or_raise() lock_file._release_lock() + def test_blocking_lock_file(self): + my_file = tempfile.mktemp() + lock_file = BlockingLockFile(my_file) + lock_file._obtain_lock() + + # next one waits for the lock + start = time.time() + wait_time = 0.1 + wait_lock = BlockingLockFile(my_file, 0.05, wait_time) + self.failUnlessRaises(IOError, wait_lock._obtain_lock) + elapsed = time.time() - start + assert elapsed <= wait_time + 0.02 # some extra time it may cost + def _cmp_contents(self, file_path, data): # raise if data from file at file_path # does not match data string |