comparison tests/conftest.py @ 806:8ac2d6045d1d

tests: Fix for time comparisons.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 23 Oct 2016 21:01:01 -0700
parents 276030ea7972
children 72f17534d58e
comparison
equal deleted inserted replaced
805:fd694f1297c7 806:8ac2d6045d1d
544 if i in left_time_indices: 544 if i in left_time_indices:
545 # This is where the time starts. Let's compare that the time 545 # This is where the time starts. Let's compare that the time
546 # values are within a few seconds of each other (usually 0 or 1). 546 # values are within a few seconds of each other (usually 0 or 1).
547 right_time_str = right[i:i + len(test_time_iso8601)] 547 right_time_str = right[i:i + len(test_time_iso8601)]
548 right_time = time.strptime(right_time_str, '%Y-%m-%dT%H:%M:%SZ') 548 right_time = time.strptime(right_time_str, '%Y-%m-%dT%H:%M:%SZ')
549 left_time = time.localtime(ctx.time) 549 left_time = time.gmtime(ctx.time)
550 difference = time.mktime(left_time) - time.mktime(right_time) 550 difference = time.mktime(left_time) - time.mktime(right_time)
551 print("Got time difference: %d" % difference) 551 print("Got time difference: %d" % difference)
552 if abs(difference) <= 2: 552 if abs(difference) <= 2:
553 print("(good enough, moving to end of timestamp)") 553 print("(good enough, moving to end of timestamp)")
554 skip_for = len(test_time_iso8601) - 1 554 skip_for = len(test_time_iso8601) - 1