[Python-checkins] cpython: Tweaked timed rollover test to allow for test-time delays.

vinay.sajip python-checkins at python.org
Thu May 5 15:18:40 CEST 2011


http://hg.python.org/cpython/rev/97004f70ff0d
changeset:   69848:97004f70ff0d
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Thu May 05 14:18:33 2011 +0100
summary:
  Tweaked timed rollover test to allow for test-time delays.

files:
  Lib/test/test_logging.py |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3491,8 +3491,12 @@
         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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list