From: Zack Cerza Date: Tue, 26 May 2020 20:33:00 +0000 (-0600) Subject: test_sh_progress(): Simplify caplog logic X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c261c3a5ce835fd910ef96fbd08bc4b88bb25f9b;p=teuthology.git test_sh_progress(): Simplify caplog logic The use of the asctime attribute appeared to be causing problems in python3 - let's use the captured attribute, which is exactly what we want anyway. Signed-off-by: Zack Cerza --- diff --git a/teuthology/test/test_misc.py b/teuthology/test/test_misc.py index bb4e67d90..bca8ed660 100644 --- a/teuthology/test/test_misc.py +++ b/teuthology/test/test_misc.py @@ -1,5 +1,4 @@ import argparse -from datetime import datetime from mock import Mock, patch from teuthology.orchestra import cluster @@ -34,6 +33,7 @@ def test_sh_fail(caplog): assert ('replay full' in record.message or 'ABC\n' == record.message) + def test_sh_progress(caplog): misc.sh("echo AB ; sleep 5 ; /bin/echo C", 2) == "ABC\n" records = caplog.records @@ -45,9 +45,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():