Failing date test
"Sebastian Spaeth" <[email protected]> Wed, 05 May 2010 13:43:55 +0200
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
I was just looking into writing a test for the empty #tag issue, however
running the test suite fails for me in this test as I have a different
timezone than you :-). I guess this needs to be fixed
======================================================================
FAIL: test_get_formatted_date (plugins.date.w3cdate.W3CDateTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/spaetz/src/pyblosxom/plugins/date/w3cdate.py", line 133, in test_get_formatted_date
"2010-01-17T15:48:20-05:00")
AssertionError: '2010-01-17T13:48:20+01:00' != '2010-01-17T15:48:20-05:00'
----------------------------------------------------------------------
I tried to fix it and it seems that I don't have xml.utils installed so
it is using the isoxxxtostring_hack function.
I finally managed to fix it with this patch which makes the test use EST
in any case. OK to push?
Sebastian
(commit a83ea86f2c87130adcffd5dbc4c797cd2851d794 in branch fix-test-timezone)
diff --git a/plugins/date/w3cdate.py b/plugins/date/w3cdate.py
index 8edda0d..c39ee63 100644
--- a/plugins/date/w3cdate.py
+++ b/plugins/date/w3cdate.py
@@ -53,6 +53,7 @@ __license__ = "Python"
import rfc822
import time
+import os
from Pyblosxom import tools
def iso8601_hack_tostring(t, timezone):
@@ -129,8 +130,19 @@ class W3CDateTest(unittest.TestCase):
def test_get_formatted_date(self):
gfd = get_formatted_date
+ #save old TZ environment for restoring
+ tz = os.environ.get('TZ')
+ #we expect US EASTERN time without DST (5h offset)
+ os.environ['TZ'] = 'EST+05EST+05,M4.1.0,M10.5.0'
+ time.tzset()
self.assertEquals(gfd(self.entry1),
"2010-01-17T15:48:20-05:00")
+ # reset time zone to whatever it was
+ if tz is None:
+ del os.environ['TZ']
+ else:
+ os.environ['TZ'] = tz
+ time.tzset()
def test_head_and_foot(self):
from Pyblosxom.pyblosxom import Request
------------------------------------------------------------------------------
_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkvhWfsACgkQVYX1jMgnoGKxhQCgj2mW8q7T/yrhlbTJnL7K1odc NGQAniyf7GyYTXc9hoCu9vsoE6iH6z7B =aBzm -----END PGP SIGNATURE-----