<s> """<STR_LIT>""" <EOL> import unittest <EOL> import time <EOL> import locale <EOL> import re <EOL> import sys <EOL> from test import test_support <EOL> from datetime import date as datetime_date <EOL> import _strptime <EOL> class getlang_Tests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_basic ( self ) : <EOL> self . failUnlessEqual ( _strptime . _getlang ( ) , locale . getlocale ( locale . LC_TIME ) ) <EOL> class LocaleTime_Tests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . time_tuple = time . localtime ( ) <EOL> self . LT_ins = _strptime . LocaleTime ( ) <EOL> def compare_against_time ( self , testing , directive , tuple_position , <EOL> error_msg ) : <EOL> """<STR_LIT>""" <EOL> strftime_output = time . strftime ( directive , self . time_tuple ) . lower ( ) <EOL> comparison = testing [ self . time_tuple [ tuple_position ] ] <EOL> self . failUnless ( strftime_output in testing , "<STR_LIT>" % <EOL> error_msg ) <EOL> self . failUnless ( comparison == strftime_output , <EOL> "<STR_LIT>" % <EOL> ( error_msg , comparison , strftime_output ) ) <EOL> def test_weekday ( self ) : <EOL> self . compare_against_time ( self . LT_ins . f_weekday , '<STR_LIT>' , <NUM_LIT:6> , <EOL> "<STR_LIT>" ) <EOL> self . compare_against_time ( self . LT_ins . a_weekday , '<STR_LIT>' , <NUM_LIT:6> , <EOL> "<STR_LIT>" ) <EOL> def test_month ( self ) : <EOL> self . compare_against_time ( self . LT_ins . f_month , '<STR_LIT>' , <NUM_LIT:1> , <EOL> "<STR_LIT>" ) <EOL> self . compare_against_time ( self . LT_ins . a_month , '<STR_LIT>' , <NUM_LIT:1> , <EOL> "<STR_LIT>" ) <EOL> def test_am_pm ( self ) : <EOL> strftime_output = time . strftime ( "<STR_LIT>" , self . time_tuple ) . lower ( ) <EOL> self . failUnless ( strftime_output in self . LT_ins . am_pm , <EOL> "<STR_LIT>" ) <EOL> if self . time_tuple [ <NUM_LIT:3> ] < <NUM_LIT:12> : position = <NUM_LIT:0> <EOL> else : position = <NUM_LIT:1> <EOL> self . failUnless ( strftime_output == self . LT_ins . am_pm [ position ] , <EOL> "<STR_LIT>" ) <EOL> def test_timezone ( self ) : <EOL> timezone = time . strftime ( "<STR_LIT>" , self . time_tuple ) . lower ( ) <EOL> if timezone : <EOL> self . failUnless ( timezone in self . LT_ins . timezone [ <NUM_LIT:0> ] or timezone in self . LT_ins . timezone [ <NUM_LIT:1> ] , <EOL> "<STR_LIT>" % <EOL> ( timezone , self . LT_ins . timezone ) ) <EOL> def test_date_time ( self ) : <EOL> magic_date = ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT:0> ) <EOL> strftime_output = time . strftime ( "<STR_LIT>" , magic_date ) <EOL> self . failUnless ( strftime_output == time . strftime ( self . LT_ins . LC_date_time , <EOL> magic_date ) , <EOL> "<STR_LIT>" ) <EOL> strftime_output = time . strftime ( "<STR_LIT>" , magic_date ) <EOL> self . failUnless ( strftime_output == time . strftime ( self . LT_ins . LC_date , <EOL> magic_date ) , <EOL> "<STR_LIT>" ) <EOL> strftime_output = time . strftime ( "<STR_LIT>" , magic_date ) <EOL> self . failUnless ( strftime_output == time . strftime ( self . LT_ins . LC_time , <EOL> magic_date ) , <EOL> "<STR_LIT>" ) <EOL> LT = _strptime . LocaleTime ( ) <EOL> LT . am_pm = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . failUnless ( LT . LC_time , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_lang ( self ) : <EOL> self . failUnlessEqual ( self . LT_ins . lang , _strptime . _getlang ( ) ) <EOL> class TimeRETests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . time_re = _strptime . TimeRE ( ) <EOL> self . locale_time = _strptime . LocaleTime ( ) <EOL> def test_pattern ( self ) : <EOL> pattern_string = self . time_re . pattern ( r"<STR_LIT>" ) <EOL> self . failUnless ( pattern_string . find ( self . locale_time . a_weekday [ <NUM_LIT:2> ] ) != - <NUM_LIT:1> , <EOL> "<STR_LIT>" % <EOL> pattern_string ) <EOL> self . failUnless ( pattern_string . find ( self . locale_time . f_weekday [ <NUM_LIT:4> ] ) != - <NUM_LIT:1> , <EOL> "<STR_LIT>" % <EOL> pattern_string ) <EOL> self . failUnless ( pattern_string . find ( self . time_re [ '<STR_LIT:d>' ] ) != - <NUM_LIT:1> , <EOL> "<STR_LIT>" % <EOL> pattern_string ) <EOL> def test_pattern_escaping ( self ) : <EOL> pattern_string = self . time_re . pattern ( "<STR_LIT>" ) <EOL> self . failUnless ( r"<STR_LIT>" in pattern_string , <EOL> "<STR_LIT>" % <EOL> pattern_string ) <EOL> def test_compile ( self ) : <EOL> found = self . time_re . compile ( r"<STR_LIT>" ) . match ( self . locale_time . f_weekday [ <NUM_LIT:6> ] ) <EOL> self . failUnless ( found and found . group ( '<STR_LIT:A>' ) == self . locale_time . f_weekday [ <NUM_LIT:6> ] , <EOL> "<STR_LIT>" ) <EOL> compiled = self . time_re . compile ( r"<STR_LIT>" ) <EOL> found = compiled . match ( "<STR_LIT>" % ( self . locale_time . a_weekday [ <NUM_LIT:4> ] , <EOL> self . locale_time . a_month [ <NUM_LIT:4> ] ) ) <EOL> self . failUnless ( found , <EOL> "<STR_LIT>" % <EOL> ( compiled . pattern , "<STR_LIT>" % ( self . locale_time . a_weekday [ <NUM_LIT:4> ] , <EOL> self . locale_time . a_month [ <NUM_LIT:4> ] ) ) ) <EOL> self . failUnless ( found . group ( '<STR_LIT:a>' ) == self . locale_time . a_weekday [ <NUM_LIT:4> ] and <EOL> found . group ( '<STR_LIT:b>' ) == self . locale_time . a_month [ <NUM_LIT:4> ] , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( found . string , found . re . pattern , found . group ( '<STR_LIT:a>' ) , <EOL> found . group ( '<STR_LIT:b>' ) ) ) <EOL> for directive in ( '<STR_LIT:a>' , '<STR_LIT:A>' , '<STR_LIT:b>' , '<STR_LIT:B>' , '<STR_LIT:c>' , '<STR_LIT:d>' , '<STR_LIT:H>' , '<STR_LIT:I>' , '<STR_LIT>' , '<STR_LIT:m>' , '<STR_LIT:M>' , '<STR_LIT:p>' , '<STR_LIT:S>' , <EOL> '<STR_LIT>' , '<STR_LIT:w>' , '<STR_LIT>' , '<STR_LIT:x>' , '<STR_LIT:X>' , '<STR_LIT:y>' , '<STR_LIT:Y>' , '<STR_LIT>' , '<STR_LIT:%>' ) : <EOL> compiled = self . time_re . compile ( "<STR_LIT:%>" + directive ) <EOL> found = compiled . match ( time . strftime ( "<STR_LIT:%>" + directive ) ) <EOL> self . failUnless ( found , "<STR_LIT>" % <EOL> ( time . strftime ( "<STR_LIT:%>" + directive ) , <EOL> compiled . pattern ) ) <EOL> def test_blankpattern ( self ) : <EOL> test_locale = _strptime . LocaleTime ( ) <EOL> test_locale . timezone = ( frozenset ( ) , frozenset ( ) ) <EOL> self . failUnless ( _strptime . TimeRE ( test_locale ) . pattern ( "<STR_LIT>" ) == '<STR_LIT>' , <EOL> "<STR_LIT>" ) <EOL> def test_matching_with_escapes ( self ) : <EOL> compiled_re = self . time_re . compile ( "<STR_LIT>" ) <EOL> found = compiled_re . match ( "<STR_LIT>" ) <EOL> self . failUnless ( found , "<STR_LIT>" ) <EOL> def test_locale_data_w_regex_metacharacters ( self ) : <EOL> locale_time = _strptime . LocaleTime ( ) <EOL> locale_time . timezone = ( frozenset ( ( "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ) ) , <EOL> frozenset ( "<STR_LIT>" ) ) <EOL> time_re = _strptime . TimeRE ( locale_time ) <EOL> self . failUnless ( time_re . compile ( "<STR_LIT>" ) . match ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_whitespace_substitution ( self ) : <EOL> pattern = self . time_re . pattern ( '<STR_LIT>' ) <EOL> self . failUnless ( not re . match ( pattern , "<STR_LIT>" ) ) <EOL> self . failUnless ( re . match ( pattern , "<STR_LIT>" ) ) <EOL> class StrptimeTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . time_tuple = time . gmtime ( ) <EOL> def test_ValueError ( self ) : <EOL> self . assertRaises ( ValueError , _strptime . strptime , data_string = "<STR_LIT>" , <EOL> format = "<STR_LIT>" ) <EOL> for bad_format in ( "<STR_LIT:%>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> try : <EOL> _strptime . strptime ( "<STR_LIT>" , bad_format ) <EOL> except ValueError : <EOL> continue <EOL> except Exception , err : <EOL> self . fail ( "<STR_LIT>" % <EOL> ( bad_format , err . __class__ . __name__ ) ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" % bad_format ) <EOL> def test_unconverteddata ( self ) : <EOL> self . assertRaises ( ValueError , _strptime . strptime , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def helper ( self , directive , position ) : <EOL> """<STR_LIT>""" <EOL> strf_output = time . strftime ( "<STR_LIT:%>" + directive , self . time_tuple ) <EOL> strp_output = _strptime . strptime ( strf_output , "<STR_LIT:%>" + directive ) <EOL> self . failUnless ( strp_output [ position ] == self . time_tuple [ position ] , <EOL> "<STR_LIT>" % <EOL> ( directive , strf_output , strp_output [ position ] , <EOL> self . time_tuple [ position ] ) ) <EOL> def test_year ( self ) : <EOL> for directive in ( '<STR_LIT:y>' , '<STR_LIT:Y>' ) : <EOL> self . helper ( directive , <NUM_LIT:0> ) <EOL> for century , bounds in ( ( <NUM_LIT> , ( '<STR_LIT>' , '<STR_LIT>' ) ) , ( <NUM_LIT> , ( '<STR_LIT>' , '<STR_LIT>' ) ) ) : <EOL> for bound in bounds : <EOL> strp_output = _strptime . strptime ( bound , '<STR_LIT>' ) <EOL> expected_result = century + int ( bound ) <EOL> self . failUnless ( strp_output [ <NUM_LIT:0> ] == expected_result , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( bound , strp_output [ <NUM_LIT:0> ] ) ) <EOL> def test_month ( self ) : <EOL> for directive in ( '<STR_LIT:B>' , '<STR_LIT:b>' , '<STR_LIT:m>' ) : <EOL> self . helper ( directive , <NUM_LIT:1> ) <EOL> def test_day ( self ) : <EOL> self . helper ( '<STR_LIT:d>' , <NUM_LIT:2> ) <EOL> def test_hour ( self ) : <EOL> self . helper ( '<STR_LIT:H>' , <NUM_LIT:3> ) <EOL> strf_output = time . strftime ( "<STR_LIT>" , self . time_tuple ) <EOL> strp_output = _strptime . strptime ( strf_output , "<STR_LIT>" ) <EOL> self . failUnless ( strp_output [ <NUM_LIT:3> ] == self . time_tuple [ <NUM_LIT:3> ] , <EOL> "<STR_LIT>" % <EOL> ( strf_output , strp_output [ <NUM_LIT:3> ] , self . time_tuple [ <NUM_LIT:3> ] ) ) <EOL> def test_minute ( self ) : <EOL> self . helper ( '<STR_LIT:M>' , <NUM_LIT:4> ) <EOL> def test_second ( self ) : <EOL> self . helper ( '<STR_LIT:S>' , <NUM_LIT:5> ) <EOL> def test_weekday ( self ) : <EOL> for directive in ( '<STR_LIT:A>' , '<STR_LIT:a>' , '<STR_LIT:w>' ) : <EOL> self . helper ( directive , <NUM_LIT:6> ) <EOL> def test_julian ( self ) : <EOL> self . helper ( '<STR_LIT>' , <NUM_LIT:7> ) <EOL> def test_timezone ( self ) : <EOL> strp_output = _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . failUnlessEqual ( strp_output . tm_isdst , <NUM_LIT:0> ) <EOL> strp_output = _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . failUnlessEqual ( strp_output . tm_isdst , <NUM_LIT:0> ) <EOL> if sys . platform == "<STR_LIT>" : <EOL> return <EOL> time_tuple = time . localtime ( ) <EOL> strf_output = time . strftime ( "<STR_LIT>" ) <EOL> strp_output = _strptime . strptime ( strf_output , "<STR_LIT>" ) <EOL> locale_time = _strptime . LocaleTime ( ) <EOL> if time . tzname [ <NUM_LIT:0> ] != time . tzname [ <NUM_LIT:1> ] or not time . daylight : <EOL> self . failUnless ( strp_output [ <NUM_LIT:8> ] == time_tuple [ <NUM_LIT:8> ] , <EOL> "<STR_LIT>" % <EOL> ( strf_output , strp_output [ <NUM_LIT:8> ] , time_tuple [ <NUM_LIT:8> ] ) ) <EOL> else : <EOL> self . failUnless ( strp_output [ <NUM_LIT:8> ] == - <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_bad_timezone ( self ) : <EOL> if sys . platform == "<STR_LIT>" : <EOL> return <EOL> tz_name = time . tzname [ <NUM_LIT:0> ] <EOL> if tz_name . upper ( ) in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> return <EOL> try : <EOL> original_tzname = time . tzname <EOL> original_daylight = time . daylight <EOL> time . tzname = ( tz_name , tz_name ) <EOL> time . daylight = <NUM_LIT:1> <EOL> tz_value = _strptime . strptime ( tz_name , "<STR_LIT>" ) [ <NUM_LIT:8> ] <EOL> self . failUnlessEqual ( tz_value , - <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( time . tzname , tz_value , time . daylight , tz_name ) ) <EOL> finally : <EOL> time . tzname = original_tzname <EOL> time . daylight = original_daylight <EOL> def test_date_time ( self ) : <EOL> for position in range ( <NUM_LIT:6> ) : <EOL> self . helper ( '<STR_LIT:c>' , position ) <EOL> def test_date ( self ) : <EOL> for position in range ( <NUM_LIT:0> , <NUM_LIT:3> ) : <EOL> self . helper ( '<STR_LIT:x>' , position ) <EOL> def test_time ( self ) : <EOL> for position in range ( <NUM_LIT:3> , <NUM_LIT:6> ) : <EOL> self . helper ( '<STR_LIT:X>' , position ) <EOL> def test_percent ( self ) : <EOL> strf_output = time . strftime ( "<STR_LIT>" , self . time_tuple ) <EOL> strp_output = _strptime . strptime ( strf_output , "<STR_LIT>" ) <EOL> self . failUnless ( strp_output [ <NUM_LIT:0> ] == self . time_tuple [ <NUM_LIT:0> ] and <EOL> strp_output [ <NUM_LIT:1> ] == self . time_tuple [ <NUM_LIT:1> ] , <EOL> "<STR_LIT>" ) <EOL> def test_caseinsensitive ( self ) : <EOL> strf_output = time . strftime ( "<STR_LIT>" , self . time_tuple ) <EOL> self . failUnless ( _strptime . strptime ( strf_output . upper ( ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> self . failUnless ( _strptime . strptime ( strf_output . lower ( ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> self . failUnless ( _strptime . strptime ( strf_output . capitalize ( ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" ) <EOL> def test_defaults ( self ) : <EOL> defaults = ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , - <NUM_LIT:1> ) <EOL> strp_output = _strptime . strptime ( '<STR_LIT:1>' , '<STR_LIT>' ) <EOL> self . failUnless ( strp_output == defaults , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( strp_output , defaults ) ) <EOL> def test_escaping ( self ) : <EOL> need_escaping = "<STR_LIT>" <EOL> self . failUnless ( _strptime . strptime ( need_escaping , need_escaping ) ) <EOL> class Strptime12AMPMTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_twelve_noon_midnight ( self ) : <EOL> eq = self . assertEqual <EOL> eq ( time . strptime ( '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:3> ] , <NUM_LIT:12> ) <EOL> eq ( time . strptime ( '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:3> ] , <NUM_LIT:0> ) <EOL> eq ( _strptime . strptime ( '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:3> ] , <NUM_LIT:12> ) <EOL> eq ( _strptime . strptime ( '<STR_LIT>' , '<STR_LIT>' ) [ <NUM_LIT:3> ] , <NUM_LIT:0> ) <EOL> class JulianTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_all_julian_days ( self ) : <EOL> eq = self . assertEqual <EOL> for i in range ( <NUM_LIT:1> , <NUM_LIT> ) : <EOL> eq ( _strptime . strptime ( '<STR_LIT>' % i , '<STR_LIT>' ) [ <NUM_LIT:7> ] , i ) <EOL> class CalculationTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . time_tuple = time . gmtime ( ) <EOL> def test_julian_calculation ( self ) : <EOL> format_string = "<STR_LIT>" <EOL> result = _strptime . strptime ( time . strftime ( format_string , self . time_tuple ) , <EOL> format_string ) <EOL> self . failUnless ( result . tm_yday == self . time_tuple . tm_yday , <EOL> "<STR_LIT>" % <EOL> ( result . tm_yday , self . time_tuple . tm_yday ) ) <EOL> def test_gregorian_calculation ( self ) : <EOL> format_string = "<STR_LIT>" <EOL> result = _strptime . strptime ( time . strftime ( format_string , self . time_tuple ) , <EOL> format_string ) <EOL> self . failUnless ( result . tm_year == self . time_tuple . tm_year and <EOL> result . tm_mon == self . time_tuple . tm_mon and <EOL> result . tm_mday == self . time_tuple . tm_mday , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( result . tm_year , result . tm_mon , result . tm_mday , <EOL> self . time_tuple . tm_year , self . time_tuple . tm_mon , <EOL> self . time_tuple . tm_mday ) ) <EOL> def test_day_of_week_calculation ( self ) : <EOL> format_string = "<STR_LIT>" <EOL> result = _strptime . strptime ( time . strftime ( format_string , self . time_tuple ) , <EOL> format_string ) <EOL> self . failUnless ( result . tm_wday == self . time_tuple . tm_wday , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( result . tm_wday , self . time_tuple . tm_wday ) ) <EOL> def test_week_of_year_and_day_of_week_calculation ( self ) : <EOL> def test_helper ( ymd_tuple , test_reason ) : <EOL> for directive in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> format_string = "<STR_LIT>" % directive <EOL> dt_date = datetime_date ( * ymd_tuple ) <EOL> strp_input = dt_date . strftime ( format_string ) <EOL> strp_output = _strptime . strptime ( strp_input , format_string ) <EOL> self . failUnless ( strp_output [ : <NUM_LIT:3> ] == ymd_tuple , <EOL> "<STR_LIT>" % <EOL> ( test_reason , directive , strp_input , <EOL> strp_output [ : <NUM_LIT:3> ] , ymd_tuple , <EOL> strp_output [ <NUM_LIT:7> ] , dt_date . timetuple ( ) [ <NUM_LIT:7> ] ) ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:8> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:7> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> ) , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:1> , <NUM_LIT:0> <NUM_LIT:7> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:0> <NUM_LIT:1> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> test_helper ( ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , "<STR_LIT>" ) <EOL> class CacheTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_time_re_recreation ( self ) : <EOL> _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> _strptime . _TimeRE_cache . locale_time . lang = "<STR_LIT>" <EOL> original_time_re = id ( _strptime . _TimeRE_cache ) <EOL> _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . failIfEqual ( original_time_re , id ( _strptime . _TimeRE_cache ) ) <EOL> self . failUnlessEqual ( len ( _strptime . _regex_cache ) , <NUM_LIT:1> ) <EOL> def test_regex_cleanup ( self ) : <EOL> try : <EOL> del _strptime . _regex_cache [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> bogus_key = <NUM_LIT:0> <EOL> while len ( _strptime . _regex_cache ) <= _strptime . _CACHE_MAX_SIZE : <EOL> _strptime . _regex_cache [ bogus_key ] = None <EOL> bogus_key += <NUM_LIT:1> <EOL> _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . failUnlessEqual ( len ( _strptime . _regex_cache ) , <NUM_LIT:1> ) <EOL> def test_new_localetime ( self ) : <EOL> locale_time_id = id ( _strptime . _TimeRE_cache . locale_time ) <EOL> _strptime . _TimeRE_cache . locale_time . lang = "<STR_LIT>" <EOL> _strptime . strptime ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . failIfEqual ( locale_time_id , <EOL> id ( _strptime . _TimeRE_cache . locale_time ) ) <EOL> def test_TimeRE_recreation ( self ) : <EOL> locale_info = locale . getlocale ( locale . LC_TIME ) <EOL> try : <EOL> locale . setlocale ( locale . LC_TIME , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> except locale . Error : <EOL> return <EOL> try : <EOL> _strptime . strptime ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> first_time_re_id = id ( _strptime . _TimeRE_cache ) <EOL> try : <EOL> locale . setlocale ( locale . LC_TIME , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> _strptime . strptime ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> second_time_re_id = id ( _strptime . _TimeRE_cache ) <EOL> self . failIfEqual ( first_time_re_id , second_time_re_id ) <EOL> except locale . Error : <EOL> pass <EOL> finally : <EOL> locale . setlocale ( locale . LC_TIME , locale_info ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( <EOL> getlang_Tests , <EOL> LocaleTime_Tests , <EOL> TimeRETests , <EOL> StrptimeTests , <EOL> Strptime12AMPMTests , <EOL> JulianTests , <EOL> CalculationTests , <EOL> CacheTests <EOL> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> test_main ( ) </s>
