Skip to content

Commit

Permalink
Don't test epoch values against naive datetimes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lunkwill42 committed Feb 27, 2024
1 parent de2a90b commit 408aaf6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/unittests/general/prefix_ip_collector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Tests for prefix_ip_collector"""

import unittest
from datetime import datetime
from datetime import datetime, timezone
from nav.activeipcollector.manager import find_range, get_timestamp


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

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

0 comments on commit 408aaf6

Please sign in to comment.