<s> import datetime <EOL> from freezegun import freeze_time <EOL> from dateutil . relativedelta import relativedelta <EOL> from datetime import timedelta , tzinfo <EOL> from tests import utils <EOL> @ freeze_time ( "<STR_LIT>" ) <EOL> def test_addition ( ) : <EOL> now = datetime . datetime . now ( ) <EOL> later = now + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> other_later = now + relativedelta ( days = <NUM_LIT:1> ) <EOL> assert utils . is_fake_datetime ( later ) <EOL> assert utils . is_fake_datetime ( other_later ) <EOL> today = datetime . date . today ( ) <EOL> tomorrow = today + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> other_tomorrow = today + relativedelta ( days = <NUM_LIT:1> ) <EOL> assert utils . is_fake_date ( tomorrow ) <EOL> assert utils . is_fake_date ( other_tomorrow ) <EOL> @ freeze_time ( "<STR_LIT>" ) <EOL> def test_subtraction ( ) : <EOL> now = datetime . datetime . now ( ) <EOL> before = now - datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> other_before = now - relativedelta ( days = <NUM_LIT:1> ) <EOL> how_long = now - before <EOL> assert utils . is_fake_datetime ( before ) <EOL> assert utils . is_fake_datetime ( other_before ) <EOL> assert isinstance ( how_long , datetime . timedelta ) <EOL> today = datetime . date . today ( ) <EOL> yesterday = today - datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> other_yesterday = today - relativedelta ( days = <NUM_LIT:1> ) <EOL> how_long = today - yesterday <EOL> assert utils . is_fake_date ( yesterday ) <EOL> assert utils . is_fake_date ( other_yesterday ) <EOL> assert isinstance ( how_long , datetime . timedelta ) <EOL> @ freeze_time ( "<STR_LIT>" ) <EOL> def test_datetime_timezone_none ( ) : <EOL> now = datetime . datetime . now ( tz = None ) <EOL> assert now == datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ) <EOL> class GMT5 ( tzinfo ) : <EOL> def utcoffset ( self , dt ) : <EOL> return timedelta ( hours = <NUM_LIT:5> ) <EOL> def tzname ( self , dt ) : <EOL> return "<STR_LIT>" <EOL> def dst ( self , dt ) : <EOL> return timedelta ( <NUM_LIT:0> ) <EOL> @ freeze_time ( "<STR_LIT>" ) <EOL> def test_datetime_timezone_real ( ) : <EOL> now = datetime . datetime . now ( tz = GMT5 ( ) ) <EOL> assert now == datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:7> , tzinfo = GMT5 ( ) ) <EOL> assert now . utcoffset ( ) == timedelta ( <NUM_LIT:0> , <NUM_LIT> * <NUM_LIT> * <NUM_LIT:5> ) <EOL> @ freeze_time ( "<STR_LIT>" , tz_offset = - <NUM_LIT:4> ) <EOL> def test_datetime_timezone_real_with_offset ( ) : <EOL> now = datetime . datetime . now ( tz = GMT5 ( ) ) <EOL> assert now == datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT:3> , tzinfo = GMT5 ( ) ) <EOL> assert now . utcoffset ( ) == timedelta ( <NUM_LIT:0> , <NUM_LIT> * <NUM_LIT> * <NUM_LIT:5> ) <EOL> @ freeze_time ( "<STR_LIT>" ) <EOL> def test_astimezone ( ) : <EOL> now = datetime . datetime . now ( tz = GMT5 ( ) ) <EOL> converted = now . astimezone ( GMT5 ( ) ) <EOL> assert utils . is_fake_datetime ( converted ) <EOL> @ freeze_time ( "<STR_LIT>" ) <EOL> def test_replace ( ) : <EOL> now = datetime . datetime . now ( ) <EOL> modified_time = now . replace ( year = <NUM_LIT> ) <EOL> assert utils . is_fake_datetime ( modified_time ) <EOL> today = datetime . date . today ( ) <EOL> modified_date = today . replace ( year = <NUM_LIT> ) <EOL> assert utils . is_fake_date ( modified_date ) </s>
