]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
test_sh_progress(): Simplify caplog logic
authorZack Cerza <zack@redhat.com>
Tue, 26 May 2020 20:33:00 +0000 (14:33 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 27 May 2020 19:39:17 +0000 (13:39 -0600)
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 <zack@redhat.com>
teuthology/test/test_misc.py

index bb4e67d90e80751e97352bcc6047a56c065ae20c..bca8ed66082fc838a68bdd5abf8e365596525a33 100644 (file)
@@ -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():