home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / test_strptime.py < prev    next >
Text File  |  2003-12-30  |  24KB  |  507 lines

  1. """PyUnit testing against strptime"""
  2.  
  3. import unittest
  4. import time
  5. import locale
  6. import re
  7. import sys
  8. from test import test_support
  9.  
  10. import _strptime
  11.  
  12. class getlang_Tests(unittest.TestCase):
  13.     """Test _getlang"""
  14.     def test_basic(self):
  15.         self.failUnlessEqual(_strptime._getlang(), locale.getlocale(locale.LC_TIME))
  16.  
  17. class LocaleTime_Tests(unittest.TestCase):
  18.     """Tests for _strptime.LocaleTime."""
  19.  
  20.     def setUp(self):
  21.         """Create time tuple based on current time."""
  22.         self.time_tuple = time.localtime()
  23.         self.LT_ins = _strptime.LocaleTime()
  24.  
  25.     def compare_against_time(self, testing, directive, tuple_position,
  26.                              error_msg):
  27.         """Helper method that tests testing against directive based on the
  28.         tuple_position of time_tuple.  Uses error_msg as error message.
  29.  
  30.         """
  31.         strftime_output = time.strftime(directive, self.time_tuple)
  32.         comparison = testing[self.time_tuple[tuple_position]]
  33.         self.failUnless(strftime_output in testing, "%s: not found in tuple" %
  34.                                                     error_msg)
  35.         self.failUnless(comparison == strftime_output,
  36.                         "%s: position within tuple incorrect; %s != %s" %
  37.                         (error_msg, comparison, strftime_output))
  38.  
  39.     def test_weekday(self):
  40.         # Make sure that full and abbreviated weekday names are correct in
  41.         # both string and position with tuple
  42.         self.compare_against_time(self.LT_ins.f_weekday, '%A', 6,
  43.                                   "Testing of full weekday name failed")
  44.         self.compare_against_time(self.LT_ins.a_weekday, '%a', 6,
  45.                                   "Testing of abbreviated weekday name failed")
  46.  
  47.     def test_month(self):
  48.         # Test full and abbreviated month names; both string and position
  49.         # within the tuple
  50.         self.compare_against_time(self.LT_ins.f_month, '%B', 1,
  51.                                   "Testing against full month name failed")
  52.         self.compare_against_time(self.LT_ins.a_month, '%b', 1,
  53.                                   "Testing against abbreviated month name failed")
  54.  
  55.     def test_am_pm(self):
  56.         # Make sure AM/PM representation done properly
  57.         strftime_output = time.strftime("%p", self.time_tuple)
  58.         self.failUnless(strftime_output in self.LT_ins.am_pm,
  59.                         "AM/PM representation not in tuple")
  60.         if self.time_tuple[3] < 12: position = 0
  61.         else: position = 1
  62.         self.failUnless(strftime_output == self.LT_ins.am_pm[position],
  63.                         "AM/PM representation in the wrong position within the tuple")
  64.  
  65.     def test_timezone(self):
  66.         # Make sure timezone is correct
  67.         timezone = time.strftime("%Z", self.time_tuple)
  68.         if timezone:
  69.             self.failUnless(timezone in self.LT_ins.timezone,
  70.                             "timezone %s not found in %s" %
  71.                             (timezone, self.LT_ins.timezone))
  72.  
  73.     def test_date_time(self):
  74.         # Check that LC_date_time, LC_date, and LC_time are correct
  75.         # the magic date is used so as to not have issues with %c when day of
  76.         #  the month is a single digit and has a leading space.  This is not an
  77.         #  issue since strptime still parses it correctly.  The problem is
  78.         #  testing these directives for correctness by comparing strftime
  79.         #  output.
  80.         magic_date = (1999, 3, 17, 22, 44, 55, 2, 76, 0)
  81.         strftime_output = time.strftime("%c", magic_date)
  82.         self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date_time,
  83.                                                          magic_date),
  84.                         "LC_date_time incorrect")
  85.         strftime_output = time.strftime("%x", magic_date)
  86.         self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date,
  87.                                                          magic_date),
  88.                         "LC_date incorrect")
  89.         strftime_output = time.strftime("%X", magic_date)
  90.         self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_time,
  91.                                                          magic_date),
  92.                         "LC_time incorrect")
  93.         LT = _strptime.LocaleTime(am_pm=('',''))
  94.         self.failUnless(LT.LC_time, "LocaleTime's LC directives cannot handle "
  95.                                     "empty strings")
  96.  
  97.     def test_lang(self):
  98.         # Make sure lang is set to what _getlang() returns
  99.         # Assuming locale has not changed between now and when self.LT_ins was created
  100.         self.failUnlessEqual(self.LT_ins.lang, _strptime._getlang())
  101.  
  102.     def test_by_hand_input(self):
  103.         # Test passed-in initialization value checks
  104.         self.failUnless(_strptime.LocaleTime(f_weekday=range(7)),
  105.                         "Argument size check for f_weekday failed")
  106.         self.assertRaises(TypeError, _strptime.LocaleTime, f_weekday=range(8))
  107.         self.assertRaises(TypeError, _strptime.LocaleTime, f_weekday=range(6))
  108.         self.failUnless(_strptime.LocaleTime(a_weekday=range(7)),
  109.                         "Argument size check for a_weekday failed")
  110.         self.assertRaises(TypeError, _strptime.LocaleTime, a_weekday=range(8))
  111.         self.assertRaises(TypeError, _strptime.LocaleTime, a_weekday=range(6))
  112.         self.failUnless(_strptime.LocaleTime(f_month=range(12)),
  113.                         "Argument size check for f_month failed")
  114.         self.assertRaises(TypeError, _strptime.LocaleTime, f_month=range(11))
  115.         self.assertRaises(TypeError, _strptime.LocaleTime, f_month=range(13))
  116.         self.failUnless(len(_strptime.LocaleTime(f_month=range(12)).f_month) == 13,
  117.                         "dummy value for f_month not added")
  118.         self.failUnless(_strptime.LocaleTime(a_month=range(12)),
  119.                         "Argument size check for a_month failed")
  120.         self.assertRaises(TypeError, _strptime.LocaleTime, a_month=range(11))
  121.         self.assertRaises(TypeError, _strptime.LocaleTime, a_month=range(13))
  122.         self.failUnless(len(_strptime.LocaleTime(a_month=range(12)).a_month) == 13,
  123.                         "dummy value for a_month not added")
  124.         self.failUnless(_strptime.LocaleTime(am_pm=range(2)),
  125.                         "Argument size check for am_pm failed")
  126.         self.assertRaises(TypeError, _strptime.LocaleTime, am_pm=range(1))
  127.         self.assertRaises(TypeError, _strptime.LocaleTime, am_pm=range(3))
  128.         self.failUnless(_strptime.LocaleTime(timezone=range(2)),
  129.                         "Argument size check for timezone failed")
  130.         self.assertRaises(TypeError, _strptime.LocaleTime, timezone=range(1))
  131.         self.assertRaises(TypeError, _strptime.LocaleTime, timezone=range(3))
  132.  
  133.     def test_unknowntimezone(self):
  134.         # Handle timezone set to ('','') properly.
  135.         # Fixes bug #661354
  136.         locale_time = _strptime.LocaleTime(timezone=('',''))
  137.         self.failUnless("%Z" not in locale_time.LC_date,
  138.                         "when timezone == ('',''), string.replace('','%Z') is "
  139.                          "occuring")
  140.  
  141. class TimeRETests(unittest.TestCase):
  142.     """Tests for TimeRE."""
  143.  
  144.     def setUp(self):
  145.         """Construct generic TimeRE object."""
  146.         self.time_re = _strptime.TimeRE()
  147.         self.locale_time = _strptime.LocaleTime()
  148.  
  149.     def test_getitem(self):
  150.         # Make sure that __getitem__ works properly
  151.         self.failUnless(self.time_re['m'],
  152.                         "Fetching 'm' directive (built-in) failed")
  153.         self.failUnless(self.time_re['b'],
  154.                         "Fetching 'b' directive (built w/ __tupleToRE) failed")
  155.         for name in self.locale_time.a_month:
  156.             self.failUnless(self.time_re['b'].find(name) != -1,
  157.                             "Not all abbreviated month names in regex")
  158.         self.failUnless(self.time_re['c'],
  159.                         "Fetching 'c' directive (built w/ format) failed")
  160.         self.failUnless(self.time_re['c'].find('%') == -1,
  161.                         "Conversion of 'c' directive failed; '%' found")
  162.         self.assertRaises(KeyError, self.time_re.__getitem__, '1')
  163.  
  164.     def test_pattern(self):
  165.         # Test TimeRE.pattern
  166.         pattern_string = self.time_re.pattern(r"%a %A %d")
  167.         self.failUnless(pattern_string.find(self.locale_time.a_weekday[2]) != -1,
  168.                         "did not find abbreviated weekday in pattern string '%s'" %
  169.                          pattern_string)
  170.         self.failUnless(pattern_string.find(self.locale_time.f_weekday[4]) != -1,
  171.                         "did not find full weekday in pattern string '%s'" %
  172.                          pattern_string)
  173.         self.failUnless(pattern_string.find(self.time_re['d']) != -1,
  174.                         "did not find 'd' directive pattern string '%s'" %
  175.                          pattern_string)
  176.  
  177.     def test_pattern_escaping(self):
  178.         # Make sure any characters in the format string that might be taken as
  179.         # regex syntax is escaped.
  180.         pattern_string = self.time_re.pattern("\d+")
  181.         self.failUnless(r"\\d\+" in pattern_string,
  182.                         "%s does not have re characters escaped properly" %
  183.                         pattern_string)
  184.  
  185.     def test_compile(self):
  186.         # Check that compiled regex is correct
  187.         found = self.time_re.compile(r"%A").match(self.locale_time.f_weekday[6])
  188.         self.failUnless(found and found.group('A') == self.locale_time.f_weekday[6],
  189.                         "re object for '%A' failed")
  190.         compiled = self.time_re.compile(r"%a %b")
  191.         found = compiled.match("%s %s" % (self.locale_time.a_weekday[4],
  192.                                self.locale_time.a_month[4]))
  193.         self.failUnless(found,
  194.             "Match failed with '%s' regex and '%s' string" %
  195.              (compiled.pattern, "%s %s" % (self.locale_time.a_weekday[4],
  196.                                            self.locale_time.a_month[4])))
  197.         self.failUnless(found.group('a') == self.locale_time.a_weekday[4] and
  198.                          found.group('b') == self.locale_time.a_month[4],
  199.                         "re object couldn't find the abbreviated weekday month in "
  200.                          "'%s' using '%s'; group 'a' = '%s', group 'b' = %s'" %
  201.                          (found.string, found.re.pattern, found.group('a'),
  202.                           found.group('b')))
  203.         for directive in ('a','A','b','B','c','d','H','I','j','m','M','p','S',
  204.                           'U','w','W','x','X','y','Y','Z','%'):
  205.             compiled = self.time_re.compile("%" + directive)
  206.             found = compiled.match(time.strftime("%" + directive))
  207.             self.failUnless(found, "Matching failed on '%s' using '%s' regex" %
  208.                                     (time.strftime("%" + directive),
  209.                                      compiled.pattern))
  210.  
  211.     def test_blankpattern(self):
  212.         # Make sure when tuple or something has no values no regex is generated.
  213.         # Fixes bug #661354
  214.         test_locale = _strptime.LocaleTime(timezone=('',''))
  215.         self.failUnless(_strptime.TimeRE(test_locale).pattern("%Z") == '',
  216.                         "with timezone == ('',''), TimeRE().pattern('%Z') != ''")
  217.  
  218.     def test_matching_with_escapes(self):
  219.         # Make sure a format that requires escaping of characters works
  220.         compiled_re = self.time_re.compile("\w+ %m")
  221.         found = compiled_re.match("\w+ 10")
  222.         self.failUnless(found, "Escaping failed of format '\w+ 10'")
  223.  
  224. class StrptimeTests(unittest.TestCase):
  225.     """Tests for _strptime.strptime."""
  226.  
  227.     def setUp(self):
  228.         """Create testing time tuple."""
  229.         self.time_tuple = time.gmtime()
  230.  
  231.     def test_TypeError(self):
  232.         # Make sure ValueError is raised when match fails
  233.         self.assertRaises(ValueError, _strptime.strptime, data_string="%d",
  234.                           format="%A")
  235.  
  236.     def test_unconverteddata(self):
  237.         # Check ValueError is raised when there is unconverted data
  238.         self.assertRaises(ValueError, _strptime.strptime, "10 12", "%m")
  239.  
  240.     def helper(self, directive, position):
  241.         """Helper fxn in testing."""
  242.         strf_output = time.strftime("%" + directive, self.time_tuple)
  243.         strp_output = _strptime.strptime(strf_output, "%" + directive)
  244.         self.failUnless(strp_output[position] == self.time_tuple[position],
  245.                         "testing of '%s' directive failed; '%s' -> %s != %s" %
  246.                          (directive, strf_output, strp_output[position],
  247.                           self.time_tuple[position]))
  248.  
  249.     def test_year(self):
  250.         # Test that the year is handled properly
  251.         for directive in ('y', 'Y'):
  252.             self.helper(directive, 0)
  253.         # Must also make sure %y values are correct for bounds set by Open Group
  254.         for century, bounds in ((1900, ('69', '99')), (2000, ('00', '68'))):
  255.             for bound in bounds:
  256.                 strp_output = _strptime.strptime(bound, '%y')
  257.                 expected_result = century + int(bound)
  258.                 self.failUnless(strp_output[0] == expected_result,
  259.                                 "'y' test failed; passed in '%s' "
  260.                                 "and returned '%s'" % (bound, strp_output[0]))
  261.  
  262.     def test_month(self):
  263.         # Test for month directives
  264.         for directive in ('B', 'b', 'm'):
  265.             self.helper(directive, 1)
  266.  
  267.     def test_day(self):
  268.         # Test for day directives
  269.         self.helper('d', 2)
  270.  
  271.     def test_hour(self):
  272.         # Test hour directives
  273.         self.helper('H', 3)
  274.         strf_output = time.strftime("%I %p", self.time_tuple)
  275.         strp_output = _strptime.strptime(strf_output, "%I %p")
  276.         self.failUnless(strp_output[3] == self.time_tuple[3],
  277.                         "testing of '%%I %%p' directive failed; '%s' -> %s != %s" %
  278.                          (strf_output, strp_output[3], self.time_tuple[3]))
  279.  
  280.     def test_minute(self):
  281.         # Test minute directives
  282.         self.helper('M', 4)
  283.  
  284.     def test_second(self):
  285.         # Test second directives
  286.         self.helper('S', 5)
  287.  
  288.     def test_weekday(self):
  289.         # Test weekday directives
  290.         for directive in ('A', 'a', 'w'):
  291.             self.helper(directive,6)
  292.  
  293.     def test_julian(self):
  294.         # Test julian directives
  295.         self.helper('j', 7)
  296.  
  297.     def test_timezone(self):
  298.         # Test timezone directives.
  299.         # When gmtime() is used with %Z, entire result of strftime() is empty.
  300.         # Check for equal timezone names deals with bad locale info when this
  301.         # occurs; first found in FreeBSD 4.4.
  302.         strp_output = _strptime.strptime("UTC", "%Z")
  303.         self.failUnlessEqual(strp_output.tm_isdst, 0)
  304.         strp_output = _strptime.strptime("GMT", "%Z")
  305.         self.failUnlessEqual(strp_output.tm_isdst, 0)
  306.         time_tuple = time.localtime()
  307.         strf_output = time.strftime("%Z")  #UTC does not have a timezone
  308.         strp_output = _strptime.strptime(strf_output, "%Z")
  309.         locale_time = _strptime.LocaleTime()
  310.         if sys.platform == 'mac':
  311.             # Timezones don't really work on MacOS9
  312.             return
  313.         if time.tzname[0] != time.tzname[1] or not time.daylight:
  314.             self.failUnless(strp_output[8] == time_tuple[8],
  315.                             "timezone check failed; '%s' -> %s != %s" %
  316.                              (strf_output, strp_output[8], time_tuple[8]))
  317.         else:
  318.             self.failUnless(strp_output[8] == -1,
  319.                             "LocaleTime().timezone has duplicate values and "
  320.                              "time.daylight but timezone value not set to -1")
  321.  
  322.     def test_bad_timezone(self):
  323.         # Explicitly test possibility of bad timezone;
  324.         # when time.tzname[0] == time.tzname[1] and time.daylight
  325.         if sys.platform == "mac":
  326.             return # MacOS9 has severely broken timezone support.
  327.         try:
  328.             original_tzname = time.tzname
  329.             original_daylight = time.daylight
  330.             time.tzname = ("PDT", "PDT")
  331.             time.daylight = 1
  332.             # Need to make sure that timezone is not calculated since that
  333.             # calls time.tzset and overrides temporary changes to time .
  334.             _strptime._locale_cache = _strptime.TimeRE(_strptime.LocaleTime(
  335.                                                     timezone=("PDT", "PDT")))
  336.             _strptime._regex_cache.clear()
  337.             tz_value = _strptime.strptime("PDT", "%Z")[8]
  338.             self.failUnlessEqual(tz_value, -1)
  339.         finally:
  340.             time.tzname = original_tzname
  341.             time.daylight = original_daylight
  342.             _strptime._locale_cache = _strptime.TimeRE()
  343.             _strptime._regex_cache.clear()
  344.  
  345.     def test_date_time(self):
  346.         # Test %c directive
  347.         for position in range(6):
  348.             self.helper('c', position)
  349.  
  350.     def test_date(self):
  351.         # Test %x directive
  352.         for position in range(0,3):
  353.             self.helper('x', position)
  354.  
  355.     def test_time(self):
  356.         # Test %X directive
  357.         for position in range(3,6):
  358.             self.helper('X', position)
  359.  
  360.     def test_percent(self):
  361.         # Make sure % signs are handled properly
  362.         strf_output = time.strftime("%m %% %Y", self.time_tuple)
  363.         strp_output = _strptime.strptime(strf_output, "%m %% %Y")
  364.         self.failUnless(strp_output[0] == self.time_tuple[0] and
  365.                          strp_output[1] == self.time_tuple[1],
  366.                         "handling of percent sign failed")
  367.  
  368.     def test_caseinsensitive(self):
  369.         # Should handle names case-insensitively.
  370.         strf_output = time.strftime("%B", self.time_tuple)
  371.         self.failUnless(_strptime.strptime(strf_output.upper(), "%B"),
  372.                         "strptime does not handle ALL-CAPS names properly")
  373.         self.failUnless(_strptime.strptime(strf_output.lower(), "%B"),
  374.                         "strptime does not handle lowercase names properly")
  375.         self.failUnless(_strptime.strptime(strf_output.capitalize(), "%B"),
  376.                         "strptime does not handle capword names properly")
  377.  
  378.     def test_defaults(self):
  379.         # Default return value should be (1900, 1, 1, 0, 0, 0, 0, 1, 0)
  380.         defaults = (1900, 1, 1, 0, 0, 0, 0, 1, -1)
  381.         strp_output = _strptime.strptime('1', '%m')
  382.         self.failUnless(strp_output == defaults,
  383.                         "Default values for strptime() are incorrect;"
  384.                         " %s != %s" % (strp_output, defaults))
  385.  
  386.     def test_escaping(self):
  387.         # Make sure all characters that have regex significance are escaped.
  388.         # Parentheses are in a purposeful order; will cause an error of
  389.         # unbalanced parentheses when the regex is compiled if they are not
  390.         # escaped.
  391.         # Test instigated by bug #796149 .
  392.         need_escaping = ".^$*+?{}\[]|)("
  393.         self.failUnless(_strptime.strptime(need_escaping, need_escaping))
  394.  
  395. class Strptime12AMPMTests(unittest.TestCase):
  396.     """Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
  397.  
  398.     def test_twelve_noon_midnight(self):
  399.         eq = self.assertEqual
  400.         eq(time.strptime('12 PM', '%I %p')[3], 12)
  401.         eq(time.strptime('12 AM', '%I %p')[3], 0)
  402.         eq(_strptime.strptime('12 PM', '%I %p')[3], 12)
  403.         eq(_strptime.strptime('12 AM', '%I %p')[3], 0)
  404.  
  405.  
  406. class JulianTests(unittest.TestCase):
  407.     """Test a _strptime regression that all julian (1-366) are accepted"""
  408.  
  409.     def test_all_julian_days(self):
  410.         eq = self.assertEqual
  411.         for i in range(1, 367):
  412.             # use 2004, since it is a leap year, we have 366 days
  413.             eq(_strptime.strptime('%d 2004' % i, '%j %Y')[7], i)
  414.  
  415. class CalculationTests(unittest.TestCase):
  416.     """Test that strptime() fills in missing info correctly"""
  417.  
  418.     def setUp(self):
  419.         self.time_tuple = time.gmtime()
  420.  
  421.     def test_julian_calculation(self):
  422.         # Make sure that when Julian is missing that it is calculated
  423.         format_string = "%Y %m %d %H %M %S %w %Z"
  424.         result = _strptime.strptime(time.strftime(format_string, self.time_tuple),
  425.                                     format_string)
  426.         self.failUnless(result.tm_yday == self.time_tuple.tm_yday,
  427.                         "Calculation of tm_yday failed; %s != %s" %
  428.                          (result.tm_yday, self.time_tuple.tm_yday))
  429.  
  430.     def test_gregorian_calculation(self):
  431.         # Test that Gregorian date can be calculated from Julian day
  432.         format_string = "%Y %H %M %S %w %j %Z"
  433.         result = _strptime.strptime(time.strftime(format_string, self.time_tuple),
  434.                                     format_string)
  435.         self.failUnless(result.tm_year == self.time_tuple.tm_year and
  436.                          result.tm_mon == self.time_tuple.tm_mon and
  437.                          result.tm_mday == self.time_tuple.tm_mday,
  438.                         "Calculation of Gregorian date failed;"
  439.                          "%s-%s-%s != %s-%s-%s" %
  440.                          (result.tm_year, result.tm_mon, result.tm_mday,
  441.                           self.time_tuple.tm_year, self.time_tuple.tm_mon,
  442.                           self.time_tuple.tm_mday))
  443.  
  444.     def test_day_of_week_calculation(self):
  445.         # Test that the day of the week is calculated as needed
  446.         format_string = "%Y %m %d %H %S %j %Z"
  447.         result = _strptime.strptime(time.strftime(format_string, self.time_tuple),
  448.                                     format_string)
  449.         self.failUnless(result.tm_wday == self.time_tuple.tm_wday,
  450.                         "Calculation of day of the week failed;"
  451.                          "%s != %s" % (result.tm_wday, self.time_tuple.tm_wday))
  452.  
  453. class CacheTests(unittest.TestCase):
  454.     """Test that caching works properly."""
  455.  
  456.     def test_time_re_recreation(self):
  457.         # Make sure cache is recreated when current locale does not match what
  458.         # cached object was created with.
  459.         _strptime.strptime("10", "%d")
  460.         _strptime._locale_cache.locale_time = _strptime.LocaleTime(lang="Ni")
  461.         original_time_re = id(_strptime._locale_cache)
  462.         _strptime.strptime("10", "%d")
  463.         self.failIfEqual(original_time_re, id(_strptime._locale_cache))
  464.  
  465.     def test_regex_cleanup(self):
  466.         # Make sure cached regexes are discarded when cache becomes "full".
  467.         try:
  468.             del _strptime._regex_cache['%d']
  469.         except KeyError:
  470.             pass
  471.         bogus_key = 0
  472.         while len(_strptime._regex_cache) <= 5:
  473.             _strptime._regex_cache[bogus_key] = None
  474.             bogus_key += 1
  475.         _strptime.strptime("10", "%d")
  476.         self.failUnlessEqual(len(_strptime._regex_cache), 1)
  477.  
  478.     def test_new_localetime(self):
  479.         # A new LocaleTime instance should be created when a new TimeRE object
  480.         # is created.
  481.         _strptime._locale_cache.locale_time = _strptime.LocaleTime(lang="Ni")
  482.         locale_time_id = id(_strptime._locale_cache.locale_time)
  483.         locale_time_lang = _strptime._locale_cache.locale_time.lang
  484.         _strptime.strptime("10", "%d")
  485.         self.failIfEqual(locale_time_id,
  486.                          id(_strptime._locale_cache.locale_time))
  487.         self.failIfEqual(locale_time_lang,
  488.                          _strptime._locale_cache.locale_time.lang)
  489.  
  490.  
  491.  
  492. def test_main():
  493.     test_support.run_unittest(
  494.         getlang_Tests,
  495.         LocaleTime_Tests,
  496.         TimeRETests,
  497.         StrptimeTests,
  498.         Strptime12AMPMTests,
  499.         JulianTests,
  500.         CalculationTests,
  501.         CacheTests
  502.     )
  503.  
  504.  
  505. if __name__ == '__main__':
  506.     test_main()
  507.