python3.x merge caused issues with python2.x compat
instead of importing division from future we simply use int() to cast floats to integers. nosetests: on python2.7 passes python2 test_ago.py: passes python3 test_ago.py: passes TODO: Does nosetests work with python3.x? branch 'default' changed ago.py changed test_ago.py
This commit is contained in:
parent
cd08476137
commit
e95b5d8c10
2 changed files with 16 additions and 9 deletions
14
test_ago.py
14
test_ago.py
|
|
@ -4,6 +4,14 @@ from datetime import timedelta
|
|||
from ago import human
|
||||
from ago import delta2dict
|
||||
|
||||
try:
|
||||
from types import StringType as STRING
|
||||
from types import DictType as DICT
|
||||
except ImportError:
|
||||
import builtins
|
||||
STRING = builtins.str
|
||||
DICT = builtins.dict
|
||||
|
||||
# datetime objects
|
||||
PRESENT = datetime.now()
|
||||
PAST = PRESENT - timedelta( 492, 58711, 45 ) # days, secs, ms
|
||||
|
|
@ -15,13 +23,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 builtins.str
|
||||
assert type(human( PAST )) is STRING
|
||||
|
||||
def test_human_passed_timedelta_is_string():
|
||||
assert type(human( PAST_DELTA )) is builtins.str
|
||||
assert type(human( PAST_DELTA )) is STRING
|
||||
|
||||
def test_delta2dict_is_dict():
|
||||
assert type(delta2dict( PAST_DELTA )) is builtins.dict
|
||||
assert type(delta2dict( PAST_DELTA )) is DICT
|
||||
|
||||
def test_ago_in_past_human():
|
||||
assert 'ago' in human( PAST )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue