<s> from __future__ import unicode_literals <EOL> import datetime <EOL> import unittest <EOL> from django . utils . timesince import timesince , timeuntil <EOL> from django . utils . tzinfo import LocalTimezone , FixedOffset <EOL> class TimesinceTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . t = datetime . datetime ( <NUM_LIT> , <NUM_LIT:8> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0> ) <EOL> self . onemicrosecond = datetime . timedelta ( microseconds = <NUM_LIT:1> ) <EOL> self . onesecond = datetime . timedelta ( seconds = <NUM_LIT:1> ) <EOL> self . oneminute = datetime . timedelta ( minutes = <NUM_LIT:1> ) <EOL> self . onehour = datetime . timedelta ( hours = <NUM_LIT:1> ) <EOL> self . oneday = datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> self . oneweek = datetime . timedelta ( days = <NUM_LIT:7> ) <EOL> self . onemonth = datetime . timedelta ( days = <NUM_LIT:30> ) <EOL> self . oneyear = datetime . timedelta ( days = <NUM_LIT> ) <EOL> def test_equal_datetimes ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( timesince ( self . t , self . t ) , '<STR_LIT>' ) <EOL> def test_ignore_microseconds_and_seconds ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( timesince ( self . t , self . t + self . onemicrosecond ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t + self . onesecond ) , <EOL> '<STR_LIT>' ) <EOL> def test_other_units ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( timesince ( self . t , self . t + self . oneminute ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t + self . onehour ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t + self . oneday ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t + self . oneweek ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t + self . onemonth ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t + self . oneyear ) , '<STR_LIT>' ) <EOL> def test_multiple_units ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t + <NUM_LIT:2> * self . oneday + <NUM_LIT:6> * self . onehour ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t + <NUM_LIT:2> * self . oneweek + <NUM_LIT:2> * self . oneday ) , '<STR_LIT>' ) <EOL> def test_display_first_unit ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t + <NUM_LIT:2> * self . oneweek + <NUM_LIT:3> * self . onehour + <NUM_LIT:4> * self . oneminute ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t + <NUM_LIT:4> * self . oneday + <NUM_LIT:5> * self . oneminute ) , '<STR_LIT>' ) <EOL> def test_display_second_before_first ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( timesince ( self . t , self . t - self . onemicrosecond ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . onesecond ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . oneminute ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . onehour ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . oneday ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . oneweek ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . onemonth ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , self . t - self . oneyear ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t - <NUM_LIT:2> * self . oneday - <NUM_LIT:6> * self . onehour ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t - <NUM_LIT:2> * self . oneweek - <NUM_LIT:2> * self . oneday ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t - <NUM_LIT:2> * self . oneweek - <NUM_LIT:3> * self . onehour - <NUM_LIT:4> * self . oneminute ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( self . t , <EOL> self . t - <NUM_LIT:4> * self . oneday - <NUM_LIT:5> * self . oneminute ) , '<STR_LIT>' ) <EOL> def test_different_timezones ( self ) : <EOL> """<STR_LIT>""" <EOL> now = datetime . datetime . now ( ) <EOL> now_tz = datetime . datetime . now ( LocalTimezone ( now ) ) <EOL> now_tz_i = datetime . datetime . now ( FixedOffset ( ( <NUM_LIT:3> * <NUM_LIT> ) + <NUM_LIT:15> ) ) <EOL> self . assertEqual ( timesince ( now ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timesince ( now_tz ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timeuntil ( now_tz , now_tz_i ) , '<STR_LIT>' ) <EOL> def test_date_objects ( self ) : <EOL> """<STR_LIT>""" <EOL> today = datetime . date . today ( ) <EOL> self . assertEqual ( timesince ( today + self . oneday ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timeuntil ( today - self . oneday ) , '<STR_LIT>' ) <EOL> def test_both_date_objects ( self ) : <EOL> """<STR_LIT>""" <EOL> today = datetime . date . today ( ) <EOL> self . assertEqual ( timeuntil ( today + self . oneday , today ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timeuntil ( today - self . oneday , today ) , '<STR_LIT>' ) <EOL> self . assertEqual ( timeuntil ( today + self . oneweek , today ) , '<STR_LIT>' ) <EOL> def test_naive_datetime_with_tzinfo_attribute ( self ) : <EOL> class naive ( datetime . tzinfo ) : <EOL> def utcoffset ( self , dt ) : <EOL> return None <EOL> future = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = naive ( ) ) <EOL> self . assertEqual ( timesince ( future ) , '<STR_LIT>' ) <EOL> past = datetime . datetime ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , tzinfo = naive ( ) ) <EOL> self . assertEqual ( timeuntil ( past ) , '<STR_LIT>' ) </s>
