Tweaked timed rollover test to allow for test-time delays.

This commit is contained in:
Vinay Sajip 2011-05-05 14:18:33 +01:00
parent 6c9f8c7e4c
commit e9a56e8d49
1 changed files with 6 additions and 2 deletions

View File

@ -3491,8 +3491,12 @@ class TimedRotatingFileHandlerTest(BaseFileTest):
fh.emit(r)
now = datetime.datetime.now()
prevsec = now - datetime.timedelta(seconds=1)
suffix = prevsec.strftime(".%Y-%m-%d_%H-%M-%S")
self.assertLogFile(self.fn + suffix)
earlier = now - datetime.timedelta(seconds=2)
fn1 = self.fn + prevsec.strftime(".%Y-%m-%d_%H-%M-%S")
fn2 = self.fn + earlier.strftime(".%Y-%m-%d_%H-%M-%S")
self.assertTrue(os.path.exists(fn1) or
os.path.exists(fn2),
msg="Neither exists: %s nor %s" % (fn1, fn2))
def test_invalid(self):
assertRaises = self.assertRaises