Changed tests and added print_function for Python 2.6 compatibility.

This commit is contained in:
sbraz 2014-02-27 14:35:30 +01:00
parent 8b45e6b8b3
commit 770fb5f3c4

View file

@ -1,17 +1,11 @@
from __future__ import print_function
from datetime import datetime
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
@ -23,13 +17,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 STRING
assert isinstance(human( PAST ), str)
def test_human_passed_timedelta_is_string():
assert type(human( PAST_DELTA )) is STRING
assert isinstance(human( PAST_DELTA ), str)
def test_delta2dict_is_dict():
assert type(delta2dict( PAST_DELTA )) is DICT
assert isinstance(delta2dict( PAST_DELTA ), dict)
def test_ago_in_past_human():
assert 'ago' in human( PAST )