Re: Failing date test

"Sebastian Spaeth" <[email protected]> Wed, 05 May 2010 13:51:17 +0200
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
On 2010-05-05, Sebastian Spaeth wrote:
> I finally managed to fix it with this patch which makes the test use EST
> in any case. OK to push?

err, OK to push?, given that I indent the if else clause properly, of course:
196ce038d26d586c7dfb98bf5509a4815996c600

diff --git a/plugins/date/w3cdate.py b/plugins/date/w3cdate.py
index 8edda0d..8c19daf 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
+        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)

iEYEARECAAYFAkvhW7UACgkQVYX1jMgnoGJ42QCfaDUKnc3glHBESARDeZh5gVKq
erEAnjg/q9X5/SAeR0M28/SeX0+CPqFm
=jISr
-----END PGP SIGNATURE-----