Skip to content

Commit 0e035a0

Browse files
committed
Fix tests
1 parent 07ddecc commit 0e035a0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/test_frame.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from logtail.frame import create_frame
44
from logtail.handler import LogtailHandler
55
from logtail.helpers import LogtailContext
6+
from sys import version_info
7+
import datetime
68
import unittest2
79
import logging
810

@@ -15,9 +17,12 @@ def test_create_frame_happy_path(self):
1517
# ISO timestamp must end with timezone info
1618
self.assertTrue(frame['dt'].endswith("+00:00"))
1719

20+
# These tests require Python >= 3.7
21+
if version_info.major == 2 or version_info.minor <= 6:
22+
return
1823
# Sent date matches log record date
19-
date_ref = datetime.utcfromtimestamp(log_record.created)
20-
date_sent = datetime.fromisoformat(frame['dt'])
24+
date_ref = datetime.datetime.utcfromtimestamp(log_record.created).replace(tzinfo=datetime.timezone.utc)
25+
date_sent = datetime.datetime.fromisoformat(frame['dt'])
2126
self.assertEqual(date_ref, date_sent)
2227

2328
def test_create_frame_with_extra(self):

0 commit comments

Comments
 (0)