From b7dbe07d009e61affb16bf459dbb88bc1c4b86ad Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Mon, 15 Nov 2021 17:37:23 -0800 Subject: [PATCH 1/2] 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 --- teuthology/test/test_misc.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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(): From 5c0b3fe3eeda6b85e447be02c110dc1973926606 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Mon, 22 Nov 2021 17:23:42 -0800 Subject: [PATCH 2/2] requirements.txt: update pytest This requires the previous commit dropping use of LogRecord.asctime Signed-off-by: Dan Mick --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c081156b35..644f723491 100644 --- a/requirements.txt +++ b/requirements.txt @@ -248,7 +248,7 @@ pyparsing==2.4.7 # packaging pyperclip==1.8.2 # via cmd2 -pytest==3.7.1 +pytest==6.2.5 # via teuthology python-cinderclient==8.0.0 # via python-openstackclient