diff options
author | Julien Jehannet <julien.jehannet@logilab.fr> | 2009-01-20 12:46:13 +0100 |
---|---|---|
committer | Julien Jehannet <julien.jehannet@logilab.fr> | 2009-01-20 12:46:13 +0100 |
commit | 35474657bdff7b708d3c8812be6386e25383095c (patch) | |
tree | e96cb3ea6bd70462354ab030e099f4d361375d02 /test/unittest_shellutils.py | |
parent | 5af9c6201892c81db1c2efd0e2ba640248e52d49 (diff) | |
download | logilab-common-35474657bdff7b708d3c8812be6386e25383095c.tar.gz |
use UserWarning instead of poor print statement
Diffstat (limited to 'test/unittest_shellutils.py')
-rw-r--r-- | test/unittest_shellutils.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/unittest_shellutils.py b/test/unittest_shellutils.py index 903312d..17bc0e0 100644 --- a/test/unittest_shellutils.py +++ b/test/unittest_shellutils.py @@ -2,6 +2,7 @@ import sys, os, tempfile, shutil from os.path import join +import datetime, time from logilab.common.testlib import TestCase, unittest_main @@ -147,7 +148,20 @@ class AcquireLockTC(TestCase): os.write(fd, '1111111111') os.close(fd) self.assertTrue(os.path.exists(self.lock)) - self.assertRaises(NoSuchProcess, acquire_lock, self.lock) + self.assertRaises(Exception, acquire_lock, self.lock, 1, 1) + + def test_wrong_process_and_continue(self): + fd = os.open(self.lock, os.O_EXCL | os.O_RDWR | os.O_CREAT) + os.write(fd, '1111111111') + os.close(fd) + self.assertTrue(os.path.exists(self.lock)) + self.assertTrue(acquire_lock(self.lock)) + + def test_locked_for_one_hour(self): + self.assertTrue(acquire_lock(self.lock)) + touch = datetime.datetime.fromtimestamp(time.time() - 3601).strftime("%m%d%H%M") + os.system("touch -t %s %s" % (touch, self.lock)) + self.assertRaises(UserWarning, acquire_lock, self.lock, max_try=2, delay=1) if __name__ == '__main__': |