Skip to content

Commit 408aaf6

Browse files
committed
Don't test epoch values against naive datetimes
When running the test suite on a machine set to the UTC timezone, `test_find_timestamp` would fail, because the datetime object used to seed the value is timezone-naive. The test would work fine in UTC+1 timezones, but not in other timezones.
1 parent de2a90b commit 408aaf6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/unittests/general/prefix_ip_collector_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""Tests for prefix_ip_collector"""
44

55
import unittest
6-
from datetime import datetime
6+
from datetime import datetime, timezone
77
from nav.activeipcollector.manager import find_range, get_timestamp
88

99

@@ -14,5 +14,5 @@ def test_find_range(self):
1414
self.assertEqual(find_range('2001:700:0:251e::/64'), 0)
1515

1616
def test_find_timestamp(self):
17-
ts = datetime(2012, 10, 4, 14, 30)
18-
self.assertEqual(get_timestamp(ts), 1349353800)
17+
ts = datetime(2012, 10, 4, 14, 30, tzinfo=timezone.utc)
18+
self.assertEqual(get_timestamp(ts), 1349361000)

0 commit comments

Comments
 (0)