Permalink
Browse files

Fix for comptatibility with python 2.6 and windows host.

  • Loading branch information...
1 parent a7ffa3d commit 83c40d76de0fb3aa05634526a8d4df18f31bf417 fbo committed Oct 22, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 tests/test_commonElements.py
@@ -62,10 +62,15 @@ def generic_time_callback_test(instance, cb):
pattern = pattern.replace(old, new)
# special cases
if pattern == "ISO8601":
- pattern = "%Y-%m-%dT%H:%M:%SZ"
+ pattern = "%Y-%m-%dT%H:%M:%SZ"
for d in DATES_TO_TEST:
if pattern == "EPOCH":
- value = d.strftime('%s') + ".%i" % (d.microsecond/1000)
+ #value = d.strftime('%s') + ".%i" % (d.microsecond/1000)
+ # Fix for windows strftime('%s'), and python timedelta total_seconds not exists in 2.6
+ td = d - datetime(1970, 1, 1)
+ total_seconds_since_epoch = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
+ value = str(total_seconds_since_epoch) + ".%i" % (d.microsecond/1000)
+ #
expected_result = datetime.utcfromtimestamp(float(value))
else:
value = d.strftime(pattern)

0 comments on commit 83c40d7

Please sign in to comment.