From: Dan Mick Date: Tue, 16 Nov 2021 01:37:23 +0000 (-0800) Subject: test_misc.py: fix bad assumption about LogRecord fields X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b7dbe07d009e61affb16bf459dbb88bc1c4b86ad;p=teuthology.git test_misc.py: fix bad assumption about LogRecord fields The test was using LogRecord's asctime attribute to calculate a time difference between two log entries. Although the attribute is documented with no caveat, others have run into the problem that it does not exist on logging.LogRecord unless a formatter with a format string referencing {asctime} has been used. Since there's a 'created' time that's more appropriate for this test anyway, use that instead. This commit enables updating pytest, because pytest's logging init code has changed: https://github.com/pytest-dev/pytest/discussions/9324 Signed-off-by: Dan Mick --- diff --git a/teuthology/test/test_misc.py b/teuthology/test/test_misc.py index 9b8fe90535..c765c04c1f 100644 --- a/teuthology/test/test_misc.py +++ b/teuthology/test/test_misc.py @@ -1,5 +1,4 @@ import argparse -from datetime import datetime from unittest.mock import Mock, patch from teuthology.orchestra import cluster @@ -45,9 +44,7 @@ def test_sh_progress(caplog): # there must be at least 2 seconds between the log record # of the first message and the log record of the second one # - t1 = datetime.strptime(records[1].asctime.split(',')[0], "%Y-%m-%d %H:%M:%S") - t2 = datetime.strptime(records[2].asctime.split(',')[0], "%Y-%m-%d %H:%M:%S") - assert (t2 - t1).total_seconds() > 2 + assert (records[2].created - records[1].created) > 2 def test_wait_until_osds_up():