[Python-checkins] python/dist/src/Lib/test test_strptime.py, 1.20, 1.21

bcannon at users.sourceforge.net bcannon at users.sourceforge.net
Mon Aug 11 01:24:08 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv1618/Lib/test

Modified Files:
	test_strptime.py 
Log Message:
Fix handling of bad locale setup where time.tzname[0] == time.tzname[1] and
time.daylight is true.  Add an explicit test for this situation.

Fixed some wording in docstrings.


Index: test_strptime.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_strptime.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** test_strptime.py	5 Aug 2003 04:02:49 -0000	1.20
--- test_strptime.py	11 Aug 2003 07:24:05 -0000	1.21
***************
*** 6,9 ****
--- 6,10 ----
  import re
  import sets
+ import sys
  from test import test_support
  
***************
*** 259,262 ****
--- 260,266 ----
          strp_output = _strptime.strptime("GMT", "%Z")
          self.failUnlessEqual(strp_output.tm_isdst, 0)
+         if sys.platform == "mac":
+             # Timezones don't really work on MacOS9
+             return
          time_tuple = time.localtime()
          strf_output = time.strftime("%Z")  #UTC does not have a timezone
***************
*** 271,274 ****
--- 275,294 ----
                              "LocaleTime().timezone has duplicate values and "
                               "time.daylight but timezone value not set to -1")
+ 
+     def test_bad_timezone(self):
+         # Explicitly test possibility of bad timezone;
+         # when time.tzname[0] == time.tzname[1] and time.daylight
+         if sys.platform == "mac":
+             return #MacOS9 has severely broken timezone support.
+         try:
+             original_tzname = time.tzname
+             original_daylight = time.daylight
+             time.tzname = ("PDT", "PDT")
+             time.daylight = 1
+             tz_value = _strptime.strptime("PDT", "%Z")[8]
+             self.failUnlessEqual(tz_value, -1)
+         finally:
+             time.tzname = original_tzname
+             time.daylight = original_daylight
  
      def test_date_time(self):





More information about the Python-checkins mailing list