changeset 1733:0ee32cdd84d8

fix 3 tests that fail on windows
author Roger Haase <crosseyedpenguin@yahoo.com>
date Thu, 23 Aug 2012 14:01:31 -0700
parents 8717df0c789c
children d4f76b82aa84
files MoinMoin/storage/backends/_tests/__init__.py MoinMoin/util/_tests/test_lock.py MoinMoin/util/_tests/test_thread_monitor.py
diffstat 3 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/storage/backends/_tests/__init__.py	Thu Aug 23 13:45:49 2012 -0700
+++ b/MoinMoin/storage/backends/_tests/__init__.py	Thu Aug 23 14:01:31 2012 -0700
@@ -60,6 +60,7 @@
         m, d = self.be.retrieve(metaid)
         assert m == meta
         assert d.read() == data
+        d.close()
         self.be.remove(metaid)
         with pytest.raises(KeyError):
             self.be.retrieve(metaid)
--- a/MoinMoin/util/_tests/test_lock.py	Thu Aug 23 13:45:49 2012 -0700
+++ b/MoinMoin/util/_tests/test_lock.py	Thu Aug 23 14:01:31 2012 -0700
@@ -80,21 +80,23 @@
     def testIsExpired(self):
         """ util.lock: ExclusiveLock: isExpired """
         timeout = 2.0
+        extra = 0.1 # extra delay to avoid occasional failure on windows
         lock = ExclusiveLock(self.lock_dir, timeout=timeout)
         if not lock.acquire(0.1):
             pytest.skip("can't acquire lock")
         assert not lock.isExpired()
-        time.sleep(timeout)
+        time.sleep(timeout + extra)
         assert lock.isExpired()
 
     def testExpire(self):
         """ util.lock: ExclusiveLock: expire """
         timeout = 2.0
+        extra = 0.1 # extra delay to avoid occasional failure on windows
         lock = ExclusiveLock(self.lock_dir, timeout=timeout)
         if not lock.acquire(0.1):
             pytest.skip("can't acquire lock")
         assert not lock.expire()
-        time.sleep(timeout)
+        time.sleep(timeout + extra)
         assert lock.expire()
 
     def testExclusive(self):
--- a/MoinMoin/util/_tests/test_thread_monitor.py	Thu Aug 23 13:45:49 2012 -0700
+++ b/MoinMoin/util/_tests/test_thread_monitor.py	Thu Aug 23 14:01:31 2012 -0700
@@ -41,5 +41,5 @@
             result = Monitor_test_obj.trigger_dump(f)
         # read the content of first line
         with open(self.src, "r") as f:
-            f.seek(1)
+            f.readline()
             assert 'Dumping thread' in f.readline()