Added Python 3 compatibility.
This commit is contained in:
parent
c1991cd380
commit
cd08476137
2 changed files with 17 additions and 19 deletions
29
test_ago.py
29
test_ago.py
|
|
@ -1,9 +1,6 @@
|
|||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
|
||||
from types import StringType
|
||||
from types import DictType
|
||||
|
||||
from ago import human
|
||||
from ago import delta2dict
|
||||
|
||||
|
|
@ -18,13 +15,13 @@ FUTURE_DELTA = PRESENT - FUTURE
|
|||
ONE_YEAR_FOUR_HOURS_DELTA = timedelta( 365, 14400, 0 )
|
||||
|
||||
def test_human_passed_datetime_is_string():
|
||||
assert type(human( PAST )) is StringType
|
||||
assert type(human( PAST )) is builtins.str
|
||||
|
||||
def test_human_passed_timedelta_is_string():
|
||||
assert type(human( PAST_DELTA )) is StringType
|
||||
assert type(human( PAST_DELTA )) is builtins.str
|
||||
|
||||
def test_delta2dict_is_dict():
|
||||
assert type(delta2dict( PAST_DELTA )) is DictType
|
||||
assert type(delta2dict( PAST_DELTA )) is builtins.dict
|
||||
|
||||
def test_ago_in_past_human():
|
||||
assert 'ago' in human( PAST )
|
||||
|
|
@ -90,18 +87,18 @@ def test_valid_future_dict():
|
|||
def example_usage():
|
||||
"""Test and example usage"""
|
||||
|
||||
print '\nTest past tense:\n'
|
||||
print delta2dict( PAST_DELTA )
|
||||
print 'Commented ' + human( PAST_DELTA, 1 )
|
||||
print human( PAST, past_tense = "Commented {} ago" )
|
||||
print('\nTest past tense:\n')
|
||||
print(delta2dict( PAST_DELTA ))
|
||||
print('Commented ' + human( PAST_DELTA, 1 ))
|
||||
print(human( PAST, past_tense = "Commented {} ago" ))
|
||||
|
||||
print human( ONE_YEAR_FOUR_HOURS_DELTA, past_tense = "Posted {} ago" )
|
||||
print(human( ONE_YEAR_FOUR_HOURS_DELTA, past_tense = "Posted {} ago" ))
|
||||
|
||||
print '\nTest future tense:\n'
|
||||
print delta2dict( FUTURE_DELTA )
|
||||
print 'Shutdown ' + human( FUTURE_DELTA, 5 )
|
||||
print human( FUTURE, future_tense = 'Shutdown in {} from now' )
|
||||
print ''
|
||||
print('\nTest future tense:\n')
|
||||
print(delta2dict( FUTURE_DELTA ))
|
||||
print('Shutdown ' + human( FUTURE_DELTA, 5 ))
|
||||
print(human( FUTURE, future_tense = 'Shutdown in {} from now' ))
|
||||
print('')
|
||||
|
||||
if __name__ == '__main__':
|
||||
example_usage()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue