<s> """<STR_LIT>""" <EOL> import unittest <EOL> from copy import deepcopy <EOL> from datetime import date <EOL> from datetime import datetime <EOL> from datetime import timedelta <EOL> from datetime import tzinfo <EOL> import mock <EOL> import pytz <EOL> from dateutil . tz import tzlocal <EOL> from dateutil . tz import tzoffset <EOL> import delorean <EOL> class GenericUTC ( tzinfo ) : <EOL> """<STR_LIT>""" <EOL> ZERO = timedelta ( <NUM_LIT:0> ) <EOL> def utcoffset ( self , dt ) : <EOL> return self . ZERO <EOL> def tzname ( self , dt ) : <EOL> return "<STR_LIT>" <EOL> def dst ( self , dt ) : <EOL> return self . ZERO <EOL> UTC = "<STR_LIT>" <EOL> generic_utc = GenericUTC ( ) <EOL> est = pytz . timezone ( "<STR_LIT>" ) . localize ( datetime . utcnow ( ) ) . tzinfo <EOL> class DeloreanTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . naive_dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . do = delorean . Delorean ( datetime = self . naive_dt , timezone = "<STR_LIT>" ) <EOL> def test_date_failure ( self ) : <EOL> dt = date ( <NUM_LIT> , <NUM_LIT:5> , <NUM_LIT:6> ) <EOL> self . assertRaises ( ValueError , delorean . Delorean , dt ) <EOL> def test_initialize_from_datetime_naive ( self ) : <EOL> self . assertRaises ( delorean . DeloreanInvalidTimezone , delorean . Delorean , datetime = self . naive_dt ) <EOL> def test_initialize_with_tzinfo_generic ( self ) : <EOL> aware_dt_generic = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = generic_utc ) <EOL> do = delorean . Delorean ( datetime = aware_dt_generic ) <EOL> self . assertTrue ( isinstance ( do , delorean . Delorean ) ) <EOL> def test_initialize_with_tzinfo_pytz ( self ) : <EOL> aware_dt_pytz = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> do = delorean . Delorean ( datetime = aware_dt_pytz ) <EOL> self . assertTrue ( isinstance ( do , delorean . Delorean ) ) <EOL> def test_initialize_with_invalid_datetime ( self ) : <EOL> self . assertRaises ( ValueError , delorean . Delorean , '<STR_LIT>' ) <EOL> def test_initialize_with_naive_datetime_with_pytz_timezone ( self ) : <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> do = delorean . Delorean ( dt , timezone = pytz . utc ) <EOL> dt = pytz . utc . localize ( dt ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , pytz . utc ) <EOL> def test_initialize_with_naive_datetime_with_dateutil_timezone ( self ) : <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> tz = tzoffset ( None , - <NUM_LIT> ) <EOL> do = delorean . Delorean ( dt , timezone = tz ) <EOL> utcoffset = tz . utcoffset ( None ) <EOL> total_seconds = ( <EOL> ( utcoffset . microseconds + ( utcoffset . seconds + utcoffset . days * <NUM_LIT> * <NUM_LIT> ) * <NUM_LIT:10> ** <NUM_LIT:6> ) / <NUM_LIT:10> ** <NUM_LIT:6> ) <EOL> tz = pytz . FixedOffset ( total_seconds / <NUM_LIT> ) <EOL> dt = tz . localize ( dt ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> def test_initialize_with_naive_datetime_with_string_timezone ( self ) : <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> tz_str = '<STR_LIT>' <EOL> tz = pytz . timezone ( tz_str ) <EOL> do = delorean . Delorean ( dt , timezone = tz_str ) <EOL> tz = tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) . tzinfo <EOL> dt = tz . localize ( dt ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> def test_initialize_with_naive_datetime_without_timezone ( self ) : <EOL> self . assertRaises ( delorean . DeloreanInvalidTimezone , delorean . Delorean , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> def test_initialize_with_datetime_with_timezone ( self ) : <EOL> dt = pytz . utc . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> do = delorean . Delorean ( dt , timezone = pytz . timezone ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , pytz . utc ) <EOL> def test_initialize_with_datetime_without_timezone ( self ) : <EOL> dt = pytz . utc . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> do = delorean . Delorean ( dt ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , pytz . utc ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_initialize_without_datetime_with_pytz_timezone ( self , mock_datetime_timezone ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> tz = dt . tzinfo <EOL> mock_datetime_timezone . return_value = dt <EOL> do = delorean . Delorean ( timezone = tz ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_initialize_without_datetime_with_dateutil_timezone ( self , mock_datetime_timezone ) : <EOL> tz = tzoffset ( None , - <NUM_LIT> ) <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = tz ) <EOL> utcoffset = tz . utcoffset ( None ) <EOL> total_seconds = ( <EOL> ( utcoffset . microseconds + ( utcoffset . seconds + utcoffset . days * <NUM_LIT> * <NUM_LIT> ) * <NUM_LIT:10> ** <NUM_LIT:6> ) / <NUM_LIT:10> ** <NUM_LIT:6> ) <EOL> tz = pytz . FixedOffset ( total_seconds / <NUM_LIT> ) <EOL> dt = tz . normalize ( dt ) <EOL> mock_datetime_timezone . return_value = dt <EOL> do = delorean . Delorean ( timezone = tz ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_initialize_without_datetime_with_string_timezone ( self , mock_datetime_timezone ) : <EOL> tz_str = '<STR_LIT>' <EOL> tz = pytz . timezone ( tz_str ) <EOL> dt = tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> tz = dt . tzinfo <EOL> mock_datetime_timezone . return_value = dt <EOL> do = delorean . Delorean ( timezone = tz_str ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_initialize_without_datetime_without_timezone ( self , mock_datetime_timezone ) : <EOL> dt = pytz . utc . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> mock_datetime_timezone . return_value = dt <EOL> do = delorean . Delorean ( ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , pytz . utc ) <EOL> def test_truncation_hour ( self ) : <EOL> self . do . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:0> ) ) <EOL> def test_midnight ( self ) : <EOL> dt = self . do . midnight <EOL> self . assertEqual ( dt , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = pytz . utc ) ) <EOL> def test_start_of_day ( self ) : <EOL> dt = self . do . start_of_day <EOL> self . assertEqual ( dt , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , tzinfo = pytz . utc ) ) <EOL> def test_end_of_day ( self ) : <EOL> dt = self . do . end_of_day <EOL> self . assertEqual ( dt , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) ) <EOL> def test_truncation_second ( self ) : <EOL> self . do . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ) ) <EOL> def test_truncation_minute ( self ) : <EOL> self . do . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_truncation_day ( self ) : <EOL> self . do . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_truncation_month ( self ) : <EOL> self . do . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_truncation_year ( self ) : <EOL> self . do . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def test_date ( self ) : <EOL> self . assertEqual ( self . do . date , date ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> def test_datetime ( self ) : <EOL> self . assertEqual ( self . do . naive , datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> def test_naive ( self ) : <EOL> dt1 = delorean . Delorean ( ) <EOL> dt_naive = dt1 . naive <EOL> self . assertEqual ( dt_naive . tzinfo , None ) <EOL> def test_naive_timezone ( self ) : <EOL> dt1 = delorean . Delorean ( timezone = "<STR_LIT>" ) . truncate ( '<STR_LIT>' ) . naive <EOL> dt2 = delorean . Delorean ( ) . truncate ( '<STR_LIT>' ) . naive <EOL> self . assertEqual ( dt2 , dt1 ) <EOL> self . assertEqual ( dt1 . tzinfo , None ) <EOL> def test_localize ( self ) : <EOL> dt = datetime . today ( ) <EOL> dt = delorean . localize ( dt , "<STR_LIT>" ) <EOL> self . assertEqual ( dt . tzinfo , pytz . utc ) <EOL> def test_failure_truncation ( self ) : <EOL> self . assertRaises ( ValueError , self . do . truncate , "<STR_LIT>" ) <EOL> def test_normalize ( self ) : <EOL> dt1 = delorean . Delorean ( ) <EOL> dt2 = delorean . Delorean ( timezone = "<STR_LIT>" ) <EOL> dt1 . truncate ( '<STR_LIT>' ) <EOL> dt2 . truncate ( '<STR_LIT>' ) <EOL> dt_normalized = delorean . normalize ( dt1 . datetime , "<STR_LIT>" ) <EOL> self . assertEqual ( dt2 . datetime , dt_normalized ) <EOL> def test_normalize_failure ( self ) : <EOL> naive_datetime = datetime . today ( ) <EOL> self . assertRaises ( ValueError , delorean . normalize , naive_datetime , "<STR_LIT>" ) <EOL> def test_localize_failure ( self ) : <EOL> dt1 = delorean . localize ( datetime . utcnow ( ) , "<STR_LIT>" ) <EOL> self . assertRaises ( ValueError , delorean . localize , dt1 , "<STR_LIT>" ) <EOL> def test_timezone ( self ) : <EOL> do_timezone = delorean . Delorean ( ) . timezone <EOL> self . assertEqual ( pytz . utc , do_timezone ) <EOL> def test_datetime_timezone_default ( self ) : <EOL> do = delorean . Delorean ( ) <EOL> do . truncate ( '<STR_LIT>' ) <EOL> dt1 = delorean . datetime_timezone ( UTC ) <EOL> self . assertEqual ( dt1 . replace ( second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> ) , do . datetime ) <EOL> def test_datetime_timezone ( self ) : <EOL> do = delorean . Delorean ( timezone = "<STR_LIT>" ) <EOL> do . truncate ( "<STR_LIT>" ) <EOL> dt1 = delorean . datetime_timezone ( tz = "<STR_LIT>" ) <EOL> self . assertEqual ( dt1 . replace ( second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> ) , do . datetime ) <EOL> def test_parse ( self ) : <EOL> do = delorean . parse ( '<STR_LIT>' ) <EOL> dt1 = pytz . utc . localize ( datetime ( <NUM_LIT> , <NUM_LIT:9> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . assertEqual ( do . datetime , dt1 ) <EOL> def test_parse_with_invalid_datetime_string ( self ) : <EOL> self . assertRaises ( ValueError , delorean . parse , '<STR_LIT>' ) <EOL> def test_parse_with_utc_year_fill ( self ) : <EOL> do = delorean . parse ( '<STR_LIT>' ) <EOL> dt1 = pytz . utc . localize ( datetime ( date . today ( ) . year , <NUM_LIT:9> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . assertEqual ( do . datetime , dt1 ) <EOL> def test_parse_with_timezone_year_fill ( self ) : <EOL> do = delorean . parse ( '<STR_LIT>' ) <EOL> dt1 = pytz . utc . localize ( datetime ( date . today ( ) . year , <NUM_LIT:9> , <NUM_LIT> , <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> self . assertEqual ( do . datetime , dt1 ) <EOL> self . assertEqual ( do . timezone . tzname ( None ) , "<STR_LIT>" ) <EOL> def test_parse_with_fixed_offset_timezone ( self ) : <EOL> tz = pytz . FixedOffset ( - <NUM_LIT> ) <EOL> dt = tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> dt_str = dt . strftime ( '<STR_LIT>' ) <EOL> do = delorean . parse ( dt_str ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_parse_with_tzlocal_timezone ( self , mock_get_local_zone ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> mock_get_local_zone . return_value = tz <EOL> dt = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = tzlocal ( ) ) <EOL> dt_str = dt . strftime ( '<STR_LIT>' ) <EOL> dt = dt . replace ( tzinfo = None ) <EOL> dt = tz . localize ( dt ) <EOL> tz = dt . tzinfo <EOL> do = delorean . parse ( dt_str ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_parse_with_tzutc_timezone ( self , mock_get_localzone ) : <EOL> mock_get_localzone . return_value = pytz . utc <EOL> dt = pytz . utc . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> dt_str = dt . strftime ( '<STR_LIT>' ) <EOL> do = delorean . parse ( dt_str ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , pytz . utc ) <EOL> def test_parse_with_timezone_parameter ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> tz = dt . tzinfo <EOL> dt_str = dt . strftime ( '<STR_LIT>' ) <EOL> do = delorean . parse ( dt_str , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> def test_parse_with_overriding_timezone_parameter ( self ) : <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = tz . localize ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> tz = dt . tzinfo <EOL> dt_str = dt . strftime ( '<STR_LIT>' ) <EOL> do = delorean . parse ( dt_str , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( do . datetime , dt ) <EOL> self . assertEqual ( do . timezone , tz ) <EOL> def test_move_namedday ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:11> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_friday ( ) <EOL> d_obj_next_2 = self . do . next_friday ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_friday ( ) <EOL> d_obj_last_2 = self . do . last_friday ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_namedday_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_namedday ( self . do . datetime , '<STR_LIT>' , '<STR_LIT>' ) <EOL> d_obj_last = delorean . move_datetime_namedday ( self . do . datetime , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_week ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:20> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_week ( ) <EOL> d_obj_next_2 = self . do . next_week ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_week ( ) <EOL> d_obj_last_2 = self . do . last_week ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_week_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_week ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_week ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_month ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:11> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_month ( ) <EOL> d_obj_next_2 = self . do . next_month ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_month ( ) <EOL> d_obj_last_2 = self . do . last_month ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_month_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_month ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_month ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_day_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_day ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_day ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_year ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_year ( ) <EOL> d_obj_next_2 = self . do . next_year ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_year ( ) <EOL> d_obj_last_2 = self . do . last_year ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_year_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_year ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_year ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_hour ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:6> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_hour ( ) <EOL> d_obj_next_2 = self . do . next_hour ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_hour ( ) <EOL> d_obj_last_2 = self . do . last_hour ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_hour_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_hour ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_hour ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_minute ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_minute ( ) <EOL> d_obj_next_2 = self . do . next_minute ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_minute ( ) <EOL> d_obj_last_2 = self . do . last_minute ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_minute_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:32> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_minute ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_minute ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_move_shift_minute ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_next_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT:16> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last_2 = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = self . do . next_second ( ) <EOL> d_obj_next_2 = self . do . next_second ( <NUM_LIT:2> ) <EOL> d_obj_last = self . do . last_second ( ) <EOL> d_obj_last_2 = self . do . last_second ( <NUM_LIT:2> ) <EOL> self . assertEqual ( dt_next , d_obj_next . datetime ) <EOL> self . assertEqual ( dt_last , d_obj_last . datetime ) <EOL> self . assertEqual ( dt_next_2 , d_obj_next_2 . datetime ) <EOL> self . assertEqual ( dt_last_2 , d_obj_last_2 . datetime ) <EOL> def test_move_second_function ( self ) : <EOL> dt_next = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT:15> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> dt_last = datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , tzinfo = pytz . utc ) <EOL> d_obj_next = delorean . move_datetime_second ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> d_obj_last = delorean . move_datetime_second ( self . do . datetime , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . assertEqual ( dt_next , d_obj_next ) <EOL> self . assertEqual ( dt_last , d_obj_last ) <EOL> def test_range_count ( self ) : <EOL> """<STR_LIT>""" <EOL> count = list ( delorean . stops ( delorean . DAILY , count = <NUM_LIT:5> ) ) <EOL> self . assertEqual ( len ( count ) , <NUM_LIT:5> ) <EOL> def test_range_with_start ( self ) : <EOL> dates1 = [ ] <EOL> for do in delorean . stops ( delorean . DAILY , count = <NUM_LIT:5> , start = datetime . utcnow ( ) ) : <EOL> do . truncate ( '<STR_LIT>' ) <EOL> dates1 . append ( do ) <EOL> do = delorean . Delorean ( ) . truncate ( '<STR_LIT>' ) <EOL> dates2 = [ ] <EOL> for x in range ( <NUM_LIT:5> ) : <EOL> dates2 . append ( do . next_day ( x ) ) <EOL> self . assertEqual ( dates1 , dates2 ) <EOL> def test_range_with_start_and_stop ( self ) : <EOL> dates1 = [ ] <EOL> tomorrow = datetime . utcnow ( ) + timedelta ( days = <NUM_LIT:1> ) <EOL> for do in delorean . stops ( delorean . DAILY , start = datetime . utcnow ( ) , stop = tomorrow ) : <EOL> do . truncate ( '<STR_LIT>' ) <EOL> dates1 . append ( do ) <EOL> do = delorean . Delorean ( ) . truncate ( '<STR_LIT>' ) <EOL> dates2 = [ ] <EOL> for x in range ( <NUM_LIT:2> ) : <EOL> dates2 . append ( do . next_day ( x ) ) <EOL> self . assertEqual ( dates1 , dates2 ) <EOL> def test_range_with_interval ( self ) : <EOL> dates1 = [ ] <EOL> for do in delorean . stops ( delorean . DAILY , interval = <NUM_LIT:2> , count = <NUM_LIT:3> , start = datetime . utcnow ( ) ) : <EOL> do . truncate ( '<STR_LIT>' ) <EOL> dates1 . append ( do ) <EOL> do = delorean . Delorean ( ) . truncate ( '<STR_LIT>' ) <EOL> dates2 = [ ] <EOL> for x in range ( <NUM_LIT:6> ) : <EOL> if ( x % <NUM_LIT:2> ) == <NUM_LIT:0> : <EOL> dates2 . append ( do . next_day ( x ) ) <EOL> self . assertEqual ( dates1 , dates2 ) <EOL> def test_delorean_with_datetime ( self ) : <EOL> dt = datetime . utcnow ( ) <EOL> d = delorean . Delorean ( datetime = dt , timezone = UTC ) <EOL> dt = pytz . utc . localize ( dt ) <EOL> self . assertEqual ( dt , d . _dt ) <EOL> self . assertEqual ( pytz . utc , d . timezone ) <EOL> def test_delorean_with_timezone ( self ) : <EOL> dt = datetime . utcnow ( ) <EOL> d = delorean . Delorean ( datetime = dt , timezone = UTC ) <EOL> d = d . shift ( "<STR_LIT>" ) <EOL> dt = pytz . utc . localize ( dt ) . astimezone ( est ) <EOL> dt = est . normalize ( dt ) <EOL> self . assertEqual ( dt , d . datetime ) <EOL> self . assertEqual ( est , d . timezone ) <EOL> def test_delorean_with_only_timezone ( self ) : <EOL> dt = datetime . utcnow ( ) <EOL> dt = pytz . utc . localize ( dt ) <EOL> dt = est . normalize ( dt ) <EOL> dt = dt . replace ( second = <NUM_LIT:0> , microsecond = <NUM_LIT:0> ) <EOL> d = delorean . Delorean ( timezone = "<STR_LIT>" ) <EOL> d . truncate ( '<STR_LIT>' ) <EOL> self . assertEqual ( est , d . timezone ) <EOL> self . assertEqual ( dt , d . _dt ) <EOL> def test_shift_failure ( self ) : <EOL> self . assertRaises ( delorean . DeloreanInvalidTimezone , self . do . shift , "<STR_LIT>" ) <EOL> def test_datetime_localization ( self ) : <EOL> dt1 = self . do . datetime <EOL> dt2 = delorean . Delorean ( dt1 ) . datetime <EOL> self . assertEqual ( dt1 , dt2 ) <EOL> def test_localize_datetime ( self ) : <EOL> dt = datetime . utcnow ( ) <EOL> tz = pytz . timezone ( "<STR_LIT>" ) <EOL> dt = tz . localize ( dt ) <EOL> d = delorean . Delorean ( dt ) <EOL> d2 = d . shift ( '<STR_LIT>' ) <EOL> self . assertEqual ( d . timezone . tzname ( None ) , "<STR_LIT>" ) <EOL> self . assertEqual ( d . datetime , dt ) <EOL> self . assertEqual ( d . datetime , d2 . datetime ) <EOL> def test_lt ( self ) : <EOL> dt1 = self . do <EOL> dt2 = delorean . Delorean ( ) <EOL> self . assertTrue ( dt1 < dt2 ) <EOL> def test_gt ( self ) : <EOL> dt1 = self . do <EOL> dt2 = delorean . Delorean ( ) <EOL> self . assertTrue ( dt2 > dt1 ) <EOL> def test_ge ( self ) : <EOL> dt = datetime . utcnow ( ) <EOL> dt1 = delorean . Delorean ( dt , timezone = "<STR_LIT>" ) <EOL> dt2 = delorean . Delorean ( dt , timezone = "<STR_LIT>" ) <EOL> dt3 = self . do <EOL> self . assertTrue ( dt2 >= dt1 ) <EOL> self . assertTrue ( dt1 >= dt3 ) <EOL> def test_le ( self ) : <EOL> dt = datetime . utcnow ( ) <EOL> dt1 = delorean . Delorean ( dt , timezone = "<STR_LIT>" ) <EOL> dt2 = delorean . Delorean ( dt , timezone = "<STR_LIT>" ) <EOL> dt3 = self . do <EOL> self . assertTrue ( dt2 <= dt1 ) <EOL> self . assertTrue ( dt3 <= dt2 ) <EOL> def test_epoch ( self ) : <EOL> unix_time = self . do . epoch <EOL> self . assertEqual ( unix_time , <NUM_LIT> ) <EOL> def test_epoch_creation ( self ) : <EOL> do = delorean . epoch ( <NUM_LIT> ) <EOL> self . assertEqual ( self . do , do ) <EOL> def test_not_equal ( self ) : <EOL> d = delorean . Delorean ( ) <EOL> self . assertNotEqual ( d , None ) <EOL> def test_equal ( self ) : <EOL> d1 = delorean . Delorean ( ) <EOL> d2 = deepcopy ( d1 ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> self . assertFalse ( d1 != d2 , '<STR_LIT>' ) <EOL> d1 = delorean . Delorean ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , timezone = '<STR_LIT>' ) <EOL> d2 = delorean . Delorean ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:8> ) , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> def test_repr_string_timezone ( self ) : <EOL> import datetime <EOL> from delorean import Delorean <EOL> d1 = Delorean ( datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , timezone = '<STR_LIT>' ) <EOL> d2 = eval ( repr ( d1 ) ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> d3 = Delorean ( d1 . datetime , timezone = '<STR_LIT>' ) <EOL> d4 = eval ( repr ( d3 ) ) <EOL> self . assertEqual ( d1 , d4 ) <EOL> def test_repr_pytz_timezone ( self ) : <EOL> import datetime <EOL> from delorean import Delorean <EOL> d1 = Delorean ( datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , timezone = '<STR_LIT>' ) <EOL> d2 = eval ( repr ( d1 ) ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> self . assertEqual ( d1 . datetime , d2 . datetime ) <EOL> self . assertEqual ( d1 . timezone , d2 . timezone ) <EOL> def test_repr_fixed_offset_timezone ( self ) : <EOL> import datetime <EOL> from delorean import Delorean <EOL> tz = pytz . timezone ( '<STR_LIT>' ) <EOL> dt = tz . localize ( datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> dt_str = dt . strftime ( '<STR_LIT>' ) <EOL> d1 = delorean . parse ( dt_str ) <EOL> d2 = eval ( repr ( d1 ) ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> self . assertEqual ( d1 . datetime , d2 . datetime ) <EOL> self . assertEqual ( d1 . timezone , d2 . timezone ) <EOL> def test_timezone_delorean_to_datetime_to_delorean_utc ( self ) : <EOL> d1 = delorean . Delorean ( ) <EOL> d2 = delorean . Delorean ( d1 . datetime ) <EOL> self . assertEqual ( d1 . next_day ( <NUM_LIT:1> ) , d2 . next_day ( <NUM_LIT:1> ) ) <EOL> self . assertEqual ( d2 . last_week ( ) , d2 . last_week ( ) ) <EOL> self . assertEqual ( d1 . timezone , d2 . timezone ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> def test_timezone_delorean_to_datetime_to_delorean_non_utc ( self ) : <EOL> """<STR_LIT>""" <EOL> d1 = delorean . Delorean ( timezone = '<STR_LIT>' ) <EOL> d2 = delorean . Delorean ( d1 . datetime ) <EOL> self . assertEqual ( d1 . next_day ( <NUM_LIT:1> ) , d2 . next_day ( <NUM_LIT:1> ) ) <EOL> self . assertEqual ( d2 . last_week ( ) , d2 . last_week ( ) ) <EOL> self . assertEqual ( d1 . timezone , d2 . timezone ) <EOL> self . assertEqual ( d1 , d2 ) <EOL> def test_stops_bymonth ( self ) : <EOL> """<STR_LIT>""" <EOL> days = list ( delorean . interface . stops ( <EOL> delorean . MONTHLY , <EOL> bymonth = ( <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:7> , <NUM_LIT:10> ) , <EOL> bymonthday = <NUM_LIT:15> , <EOL> count = <NUM_LIT:4> , <EOL> start = datetime ( datetime . now ( ) . year , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> ) <EOL> year = datetime . now ( ) . year <EOL> day = <NUM_LIT:15> <EOL> dt1 = datetime ( year , <NUM_LIT:1> , day ) <EOL> dt4 = datetime ( year , <NUM_LIT:4> , day ) <EOL> dt7 = datetime ( year , <NUM_LIT:7> , day ) <EOL> dt10 = datetime ( year , <NUM_LIT:10> , day ) <EOL> self . assertTrue ( len ( days ) == <NUM_LIT:4> ) <EOL> dl1 = delorean . Delorean ( datetime = dt1 , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( days [ <NUM_LIT:0> ] , dl1 ) <EOL> dl4 = delorean . Delorean ( datetime = dt4 , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( days [ <NUM_LIT:1> ] , dl4 ) <EOL> dl7 = delorean . Delorean ( datetime = dt7 , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( days [ <NUM_LIT:2> ] , dl7 ) <EOL> dl10 = delorean . Delorean ( datetime = dt10 , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( days [ <NUM_LIT:3> ] , dl10 ) <EOL> def test_timedelta_arithmetic ( self ) : <EOL> hour = timedelta ( hours = <NUM_LIT:1> ) <EOL> d = delorean . parse ( "<STR_LIT>" ) <EOL> hour_before = delorean . parse ( "<STR_LIT>" ) <EOL> hour_after = delorean . parse ( "<STR_LIT>" ) <EOL> self . assertEqual ( d + hour , hour_after ) <EOL> self . assertEqual ( d - hour , hour_before ) <EOL> self . assertEqual ( hour_after - d , hour ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_humanize_past ( self , mock_now ) : <EOL> mock_now . return_value = delorean . Delorean ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:2> ) , timezone = '<STR_LIT>' ) <EOL> do = delorean . Delorean ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( do . humanize ( ) , '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_humanize_future ( self , mock_now ) : <EOL> mock_now . return_value = delorean . Delorean ( datetime ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , timezone = '<STR_LIT>' ) <EOL> do = delorean . Delorean ( datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) , timezone = '<STR_LIT>' ) <EOL> self . assertEqual ( do . humanize ( ) , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
