<s> import sys , os , os . path <EOL> import unittest , doctest <EOL> try : <EOL> import cPickle as pickle <EOL> except ImportError : <EOL> import pickle <EOL> from datetime import datetime , time , timedelta , tzinfo <EOL> import warnings <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( os . path . join ( os . pardir , os . pardir ) ) ) <EOL> import pytz <EOL> from pytz import reference <EOL> from pytz . tzfile import _byte_string <EOL> from pytz . tzinfo import DstTzInfo , StaticTzInfo <EOL> EXPECTED_VERSION = '<STR_LIT>' <EOL> EXPECTED_OLSON_VERSION = '<STR_LIT>' <EOL> fmt = '<STR_LIT>' <EOL> NOTIME = timedelta ( <NUM_LIT:0> ) <EOL> UTC = pytz . timezone ( '<STR_LIT>' ) <EOL> GMT = pytz . timezone ( '<STR_LIT>' ) <EOL> assert isinstance ( GMT , StaticTzInfo ) , '<STR_LIT>' <EOL> def prettydt ( dt ) : <EOL> """<STR_LIT>""" <EOL> if dt . utcoffset ( ) >= timedelta ( <NUM_LIT:0> ) : <EOL> offset = '<STR_LIT>' % ( dt . utcoffset ( ) , ) <EOL> else : <EOL> offset = '<STR_LIT>' % ( - <NUM_LIT:1> * dt . utcoffset ( ) , ) <EOL> return '<STR_LIT>' % ( <EOL> dt . year , dt . month , dt . day , <EOL> dt . hour , dt . minute , dt . second , <EOL> dt . tzname ( ) , offset ) <EOL> try : <EOL> unicode <EOL> except NameError : <EOL> unicode = str <EOL> class BasicTest ( unittest . TestCase ) : <EOL> def testVersion ( self ) : <EOL> self . assertEqual ( EXPECTED_VERSION , pytz . __version__ , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % ( EXPECTED_VERSION , pytz . __version__ ) ) <EOL> self . assertEqual ( EXPECTED_OLSON_VERSION , pytz . OLSON_VERSION , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> % ( EXPECTED_OLSON_VERSION , pytz . OLSON_VERSION ) ) <EOL> def testGMT ( self ) : <EOL> now = datetime . now ( tz = GMT ) <EOL> self . assertTrue ( now . utcoffset ( ) == NOTIME ) <EOL> self . assertTrue ( now . dst ( ) == NOTIME ) <EOL> self . assertTrue ( now . timetuple ( ) == now . utctimetuple ( ) ) <EOL> self . assertTrue ( now == now . replace ( tzinfo = UTC ) ) <EOL> def testReferenceUTC ( self ) : <EOL> now = datetime . now ( tz = UTC ) <EOL> self . assertTrue ( now . utcoffset ( ) == NOTIME ) <EOL> self . assertTrue ( now . dst ( ) == NOTIME ) <EOL> self . assertTrue ( now . timetuple ( ) == now . utctimetuple ( ) ) <EOL> def testUnknownOffsets ( self ) : <EOL> dst_tz = pytz . timezone ( '<STR_LIT>' ) <EOL> self . assertTrue ( dst_tz . utcoffset ( None ) is None ) <EOL> self . assertTrue ( dst_tz . dst ( None ) is None ) <EOL> self . assertEqual ( dst_tz . tzname ( None ) , '<STR_LIT>' ) <EOL> def clearCache ( self ) : <EOL> pytz . _tzinfo_cache . clear ( ) <EOL> def testUnicodeTimezone ( self ) : <EOL> self . clearCache ( ) <EOL> eastern = pytz . timezone ( unicode ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( eastern is pytz . timezone ( '<STR_LIT>' ) ) <EOL> self . clearCache ( ) <EOL> eastern = pytz . timezone ( '<STR_LIT>' ) <EOL> self . assertTrue ( eastern is pytz . timezone ( unicode ( '<STR_LIT>' ) ) ) <EOL> class PicklingTest ( unittest . TestCase ) : <EOL> def _roundtrip_tzinfo ( self , tz ) : <EOL> p = pickle . dumps ( tz ) <EOL> unpickled_tz = pickle . loads ( p ) <EOL> self . assertTrue ( tz is unpickled_tz , '<STR_LIT>' % tz . zone ) <EOL> def _roundtrip_datetime ( self , dt ) : <EOL> tz = dt . tzinfo <EOL> p = pickle . dumps ( dt ) <EOL> unpickled_dt = pickle . loads ( p ) <EOL> unpickled_tz = unpickled_dt . tzinfo <EOL> self . assertTrue ( tz is unpickled_tz , '<STR_LIT>' % tz . zone ) <EOL> def testDst ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> for localized_tz in tz . _tzinfos . values ( ) : <EOL> self . _roundtrip_tzinfo ( localized_tz ) <EOL> self . _roundtrip_datetime ( dt . replace ( tzinfo = localized_tz ) ) <EOL> def testRoundtrip ( self ) : <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> for zone in pytz . all_timezones : <EOL> tz = pytz . timezone ( zone ) <EOL> self . _roundtrip_tzinfo ( tz ) <EOL> def testDatabaseFixes ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> p = pickle . dumps ( tz ) <EOL> tzname = tz . _tzname <EOL> hacked_p = p . replace ( _byte_string ( tzname ) , <EOL> _byte_string ( '<STR_LIT:?>' * len ( tzname ) ) ) <EOL> self . assertNotEqual ( p , hacked_p ) <EOL> unpickled_tz = pickle . loads ( hacked_p ) <EOL> self . assertTrue ( tz is unpickled_tz ) <EOL> p = pickle . dumps ( tz ) <EOL> new_utcoffset = tz . _utcoffset . seconds + <NUM_LIT> <EOL> old_pickle_pattern = pickle . dumps ( tz . _utcoffset . seconds ) [ <NUM_LIT:3> : - <NUM_LIT:1> ] <EOL> new_pickle_pattern = pickle . dumps ( new_utcoffset ) [ <NUM_LIT:3> : - <NUM_LIT:1> ] <EOL> hacked_p = p . replace ( old_pickle_pattern , new_pickle_pattern ) <EOL> self . assertNotEqual ( p , hacked_p ) <EOL> unpickled_tz = pickle . loads ( hacked_p ) <EOL> self . assertEqual ( unpickled_tz . _utcoffset . seconds , new_utcoffset ) <EOL> self . assertTrue ( tz is not unpickled_tz ) <EOL> def testOldPickles ( self ) : <EOL> east1 = pickle . loads ( _byte_string ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) ) <EOL> east2 = pytz . timezone ( '<STR_LIT>' ) . localize ( <EOL> datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) . tzinfo <EOL> self . assertTrue ( east1 is east2 ) <EOL> pap1 = pickle . loads ( _byte_string ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> pap2 = pytz . timezone ( '<STR_LIT>' ) . localize ( <EOL> datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) . tzinfo <EOL> self . assertTrue ( pap1 is pap2 ) <EOL> gmt1 = pickle . loads ( _byte_string ( <EOL> "<STR_LIT>" ) ) <EOL> gmt2 = pytz . timezone ( '<STR_LIT>' ) <EOL> self . assertTrue ( gmt1 is gmt2 ) <EOL> class USEasternDSTStartTestCase ( unittest . TestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:7> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> instant = timedelta ( seconds = <NUM_LIT:1> ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:5> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> def _test_tzname ( self , utc_dt , wanted ) : <EOL> tzname = wanted [ '<STR_LIT>' ] <EOL> dt = utc_dt . astimezone ( self . tzinfo ) <EOL> self . assertEqual ( dt . tzname ( ) , tzname , <EOL> '<STR_LIT>' % ( <EOL> tzname , str ( utc_dt ) , dt . tzname ( ) <EOL> ) <EOL> ) <EOL> def _test_utcoffset ( self , utc_dt , wanted ) : <EOL> utcoffset = wanted [ '<STR_LIT>' ] <EOL> dt = utc_dt . astimezone ( self . tzinfo ) <EOL> self . assertEqual ( <EOL> dt . utcoffset ( ) , wanted [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' % ( <EOL> utcoffset , utc_dt , dt . utcoffset ( ) <EOL> ) <EOL> ) <EOL> def _test_dst ( self , utc_dt , wanted ) : <EOL> dst = wanted [ '<STR_LIT>' ] <EOL> dt = utc_dt . astimezone ( self . tzinfo ) <EOL> self . assertEqual ( dt . dst ( ) , dst , <EOL> '<STR_LIT>' % ( <EOL> dst , utc_dt , dt . dst ( ) <EOL> ) <EOL> ) <EOL> def test_arithmetic ( self ) : <EOL> utc_dt = self . transition_time <EOL> for days in range ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> ) : <EOL> delta = timedelta ( days = days ) <EOL> dt = utc_dt . astimezone ( self . tzinfo ) <EOL> dt2 = dt + delta <EOL> dt2 = dt2 - delta <EOL> self . assertEqual ( dt , dt2 ) <EOL> utc_plus_delta = ( utc_dt + delta ) . astimezone ( self . tzinfo ) <EOL> local_plus_delta = self . tzinfo . normalize ( dt + delta ) <EOL> self . assertEqual ( <EOL> prettydt ( utc_plus_delta ) , <EOL> prettydt ( local_plus_delta ) , <EOL> '<STR_LIT>' % ( <EOL> days , <EOL> prettydt ( utc_plus_delta ) , <EOL> prettydt ( local_plus_delta ) , <EOL> ) <EOL> ) <EOL> def _test_all ( self , utc_dt , wanted ) : <EOL> self . _test_utcoffset ( utc_dt , wanted ) <EOL> self . _test_tzname ( utc_dt , wanted ) <EOL> self . _test_dst ( utc_dt , wanted ) <EOL> def testDayBefore ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time - timedelta ( days = <NUM_LIT:1> ) , self . before <EOL> ) <EOL> def testTwoHoursBefore ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time - timedelta ( hours = <NUM_LIT:2> ) , self . before <EOL> ) <EOL> def testHourBefore ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time - timedelta ( hours = <NUM_LIT:1> ) , self . before <EOL> ) <EOL> def testInstantBefore ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time - self . instant , self . before <EOL> ) <EOL> def testTransition ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time , self . after <EOL> ) <EOL> def testInstantAfter ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time + self . instant , self . after <EOL> ) <EOL> def testHourAfter ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time + timedelta ( hours = <NUM_LIT:1> ) , self . after <EOL> ) <EOL> def testTwoHoursAfter ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time + timedelta ( hours = <NUM_LIT:1> ) , self . after <EOL> ) <EOL> def testDayAfter ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time + timedelta ( days = <NUM_LIT:1> ) , self . after <EOL> ) <EOL> class USEasternDSTEndTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:5> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:0> ) , <EOL> } <EOL> class USEasternEPTStartTestCase ( USEasternDSTStartTestCase ) : <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> class USEasternEPTEndTestCase ( USEasternDSTStartTestCase ) : <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT:30> , <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:4> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:5> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:0> ) , <EOL> } <EOL> class WarsawWMTEndTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> , minutes = <NUM_LIT> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> class VilniusWMTEndTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> instant = timedelta ( seconds = <NUM_LIT> ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> , minutes = <NUM_LIT> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> , minutes = <NUM_LIT> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> class VilniusCESTStartTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:3> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:2> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> class LondonHistoryStartTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> class LondonHistoryEndTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> class NoumeaHistoryStartTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:12> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:12> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:11> , minutes = <NUM_LIT:6> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:11> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> class NoumeaDSTEndTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:12> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:11> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> class NoumeaNoMoreDSTTestCase ( NoumeaDSTEndTestCase ) : <EOL> transition_time = ( <EOL> NoumeaDSTEndTestCase . transition_time + timedelta ( days = <NUM_LIT> * <NUM_LIT:10> ) ) <EOL> before = NoumeaDSTEndTestCase . after <EOL> after = NoumeaDSTEndTestCase . after <EOL> class TahitiTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:9> , <NUM_LIT> , <NUM_LIT:16> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:9> , minutes = - <NUM_LIT> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:10> ) , <EOL> '<STR_LIT>' : timedelta ( <NUM_LIT:0> ) , <EOL> } <EOL> class SamoaInternationalDateLineChange ( USEasternDSTStartTestCase ) : <EOL> tzinfo = pytz . timezone ( '<STR_LIT>' ) <EOL> transition_time = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:30> , <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) <EOL> before = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = - <NUM_LIT:10> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> after = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT> ) , <EOL> '<STR_LIT>' : timedelta ( hours = <NUM_LIT:1> ) , <EOL> } <EOL> class ReferenceUSEasternDSTStartTestCase ( USEasternDSTStartTestCase ) : <EOL> tzinfo = reference . Eastern <EOL> def test_arithmetic ( self ) : <EOL> pass <EOL> class ReferenceUSEasternDSTEndTestCase ( USEasternDSTEndTestCase ) : <EOL> tzinfo = reference . Eastern <EOL> def testHourBefore ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time - timedelta ( hours = <NUM_LIT:1> ) , self . after <EOL> ) <EOL> def testInstantBefore ( self ) : <EOL> self . _test_all ( <EOL> self . transition_time - timedelta ( seconds = <NUM_LIT:1> ) , self . after <EOL> ) <EOL> def test_arithmetic ( self ) : <EOL> pass <EOL> class LocalTestCase ( unittest . TestCase ) : <EOL> def testLocalize ( self ) : <EOL> loc_tz = pytz . timezone ( '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:20> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:10> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:20> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_tz = pytz . timezone ( '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) , is_dst = <NUM_LIT:1> ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) , is_dst = <NUM_LIT:0> ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertRaises ( pytz . AmbiguousTimeError , <EOL> loc_tz . localize , datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> ) , is_dst = None <EOL> ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ) , is_dst = <NUM_LIT:0> ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ) , is_dst = <NUM_LIT:1> ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> self . assertRaises ( pytz . NonExistentTimeError , <EOL> loc_tz . localize , datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> ) , is_dst = None <EOL> ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:9> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT:30> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , is_dst = <NUM_LIT:1> ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> loc_time = loc_tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT:30> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) , is_dst = <NUM_LIT:0> ) <EOL> self . assertEqual ( loc_time . strftime ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> for zonename , ambiguous_naive , expected in [ <EOL> ( '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) , <EOL> [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) , <EOL> ( '<STR_LIT>' , datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:30> ) , <EOL> [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) ] : <EOL> loc_tz = pytz . timezone ( zonename ) <EOL> self . assertRaises ( pytz . AmbiguousTimeError , <EOL> loc_tz . localize , ambiguous_naive , is_dst = None <EOL> ) <EOL> for dst in [ True , timedelta ( <NUM_LIT:1> ) , False , timedelta ( <NUM_LIT:0> ) ] : <EOL> loc_time = loc_tz . localize ( ambiguous_naive , is_dst = dst ) <EOL> self . assertEqual ( loc_time . strftime ( fmt ) , expected [ not dst ] ) <EOL> def testNormalize ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT:7> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = UTC ) . astimezone ( tz ) <EOL> dt2 = dt - timedelta ( minutes = <NUM_LIT:10> ) <EOL> self . assertEqual ( <EOL> dt2 . strftime ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> dt2 = tz . normalize ( dt2 ) <EOL> self . assertEqual ( <EOL> dt2 . strftime ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def testPartialMinuteOffsets ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> utc_dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = UTC ) <EOL> utc_dt = utc_dt . replace ( second = <NUM_LIT:0> ) <EOL> loc_dt = utc_dt . astimezone ( tz ) <EOL> self . assertEqual ( <EOL> loc_dt . strftime ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> utc_dt = loc_dt . astimezone ( UTC ) <EOL> self . assertEqual ( <EOL> utc_dt . strftime ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> def no_testCreateLocaltime ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = tz ) <EOL> self . assertEqual ( <EOL> dt . strftime ( fmt ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> class CommonTimezonesTestCase ( unittest . TestCase ) : <EOL> def test_bratislava ( self ) : <EOL> self . assertTrue ( '<STR_LIT>' in pytz . common_timezones ) <EOL> self . assertTrue ( '<STR_LIT>' in pytz . common_timezones_set ) <EOL> def test_us_eastern ( self ) : <EOL> self . assertTrue ( '<STR_LIT>' in pytz . common_timezones ) <EOL> self . assertTrue ( '<STR_LIT>' in pytz . common_timezones_set ) <EOL> def test_belfast ( self ) : <EOL> self . assertTrue ( '<STR_LIT>' in pytz . all_timezones_set ) <EOL> self . assertFalse ( '<STR_LIT>' in pytz . common_timezones ) <EOL> self . assertFalse ( '<STR_LIT>' in pytz . common_timezones_set ) <EOL> class BaseTzInfoTestCase : <EOL> '''<STR_LIT>''' <EOL> tz = None <EOL> tz_class = None <EOL> def test_expectedclass ( self ) : <EOL> self . assertTrue ( isinstance ( self . tz , self . tz_class ) ) <EOL> def test_fromutc ( self ) : <EOL> dt1 = datetime ( <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> ) <EOL> dt2 = self . tz . localize ( dt1 ) <EOL> for dt in [ dt1 , dt2 ] : <EOL> loc_dt = self . tz . fromutc ( dt ) <EOL> loc_dt2 = pytz . utc . localize ( dt1 ) . astimezone ( self . tz ) <EOL> self . assertEqual ( loc_dt , loc_dt2 ) <EOL> new_tz = pytz . timezone ( '<STR_LIT>' ) <EOL> self . assertTrue ( self . tz is not new_tz ) <EOL> dt3 = new_tz . localize ( dt1 ) <EOL> self . assertRaises ( ValueError , self . tz . fromutc , dt3 ) <EOL> def test_normalize ( self ) : <EOL> other_tz = pytz . timezone ( '<STR_LIT>' ) <EOL> self . assertTrue ( self . tz is not other_tz ) <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:0> ) <EOL> other_dt = other_tz . localize ( dt ) <EOL> local_dt = self . tz . normalize ( other_dt ) <EOL> self . assertTrue ( local_dt . tzinfo is not other_dt . tzinfo ) <EOL> self . assertNotEqual ( <EOL> local_dt . replace ( tzinfo = None ) , other_dt . replace ( tzinfo = None ) ) <EOL> def test_astimezone ( self ) : <EOL> other_tz = pytz . timezone ( '<STR_LIT>' ) <EOL> self . assertTrue ( self . tz is not other_tz ) <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:0> ) <EOL> other_dt = other_tz . localize ( dt ) <EOL> local_dt = other_dt . astimezone ( self . tz ) <EOL> self . assertTrue ( local_dt . tzinfo is not other_dt . tzinfo ) <EOL> self . assertNotEqual ( <EOL> local_dt . replace ( tzinfo = None ) , other_dt . replace ( tzinfo = None ) ) <EOL> class OptimizedUTCTestCase ( unittest . TestCase , BaseTzInfoTestCase ) : <EOL> tz = pytz . utc <EOL> tz_class = tz . __class__ <EOL> class LegacyUTCTestCase ( unittest . TestCase , BaseTzInfoTestCase ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> tz_class = StaticTzInfo <EOL> class StaticTzInfoTestCase ( unittest . TestCase , BaseTzInfoTestCase ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> tz_class = StaticTzInfo <EOL> class DstTzInfoTestCase ( unittest . TestCase , BaseTzInfoTestCase ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> tz_class = DstTzInfo <EOL> def test_suite ( ) : <EOL> suite = unittest . TestSuite ( ) <EOL> suite . addTest ( doctest . DocTestSuite ( '<STR_LIT>' ) ) <EOL> suite . addTest ( doctest . DocTestSuite ( '<STR_LIT>' ) ) <EOL> import test_tzinfo <EOL> suite . addTest ( unittest . defaultTestLoader . loadTestsFromModule ( test_tzinfo ) ) <EOL> return suite <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> warnings . simplefilter ( "<STR_LIT:error>" ) <EOL> unittest . main ( defaultTest = '<STR_LIT>' ) </s>
