I’m not sure what to make of this, whether it’s a bug, fragile tests, and expected failure, or something else?
Three unit tests fail in latest trunk (r12624 on Ubuntu 13.10/Python 2.7.5, set to the UK timezone. It appears that trac.util.to_datetime() returns a datetime object that is 1 hour ahead of that returned by datetime.fromtimestamp() when a timestamp is provided.
I should mention that in January 1970 UK wall clock time was 1 hour ahead of UTC. This was changed in October 1971, since then the UK has been on GMT (UTC+0) during winter months.
Regards, Alex
(venv)willmerae@ubuntu:~/src/trac$ PYTHONPATH=. python trac/util/tests/datefmt.py
................F.FF...................................................................................
======================================================================
FAIL: test_to_datetime (__main__.DateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 716, in test_to_datetime
self.assertEqual(datefmt.to_datetime(23), expected)
AssertionError: datetime.datetime(1970, 1, 1, 2, 0, 23, tzinfo=<LocalTimezone "GMT" 0:00:00>) != datetime.datetime(1970, 1, 1, 1, 0, 23, tzinfo=<LocalTimezone "GMT" 0:00:00>)
======================================================================
FAIL: test_to_datetime_microsecond_negative_timestamps (__main__.DateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 734, in test_to_datetime_microsecond_negative_timestamps
self.assertEqual(datefmt.to_datetime(-2345678912), expected)
AssertionError: datetime.datetime(1970, 1, 1, 1, 20, 54, 321088, tzinfo=<LocalTimezone "GMT" 0:00:00>) != datetime.datetime(1970, 1, 1, 0, 20, 54, 321088, tzinfo=<LocalTimezone "GMT" 0:00:00>)
======================================================================
FAIL: test_to_datetime_microsecond_timestamps (__main__.DateFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "trac/util/tests/datefmt.py", line 723, in test_to_datetime_microsecond_timestamps
self.assertEqual(datefmt.to_datetime(2345678912), expected)
AssertionError: datetime.datetime(1970, 1, 1, 2, 39, 5, 678912, tzinfo=<LocalTimezone "GMT" 0:00:00>) != datetime.datetime(1970, 1, 1, 1, 39, 5, 678912, tzinfo=<LocalTimezone "GMT" 0:00:00>)
----------------------------------------------------------------------
Ran 103 tests in 0.355s
FAILED (failures=3)
(venv)willmerae@ubuntu:~/src/trac$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 13.10
Release: 13.10
Codename: saucy
(venv)willmerae@ubuntu:~/src/trac$ uname -a
Linux ubuntu 3.11.0-17-generic #31-Ubuntu SMP Mon Feb 3 21:52:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
(venv)willmerae@ubuntu:~/src/trac$ python --version
Python 2.7.5+
(venv)willmerae@ubuntu:~/src/trac$ python -c 'import pytz; print pytz.__version__'
2014.2
--
Alex Willmer | #define Developer
Application Services | CGI
2 Trinity Park, Birmingham, B37 7ES, UK
al.wi...@cgi.com | cgi-group.co.uk
CGI IT UK Limited. A CGI Group Inc. Company
Registered Office: 250 Brook Drive, Green Park, Reading RG2 6UA, United Kingdom. Registered in England & Wales - Number 947968
CONFIDENTIALITY NOTICE: Proprietary/Confidential Information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail.