moved test to its own file

This commit is contained in:
RussellBallestrini 2013-01-07 21:57:22 -05:00
parent ec3cf8fbfb
commit 9406a387a2
2 changed files with 30 additions and 25 deletions

28
ago.py
View file

@ -30,29 +30,7 @@ def human( d1, precision = 2 ):
delta = d2 - d1
if d2 < d1: delta = d1 - d2
return delta2human( delta, precision )
def test():
"""Test and example usage"""
from datetime import datetime
from datetime import timedelta
present = datetime.now()
past = present - timedelta( 492, 58711, 45 ) # days, secs, ms
future = present + timedelta( 2, 12447, 963 ) # days, secs, ms
pdelta = present - past
fdelta = future - present
print '\nTesting past:\n'
print delta2dict( pdelta )
print 'Commented ' + delta2human( pdelta, 3 ) + ' ago'
print 'Commented ' + human( past ) + ' ago'
print '\nTesting future:\n'
print delta2dict( fdelta )
print 'Shutdown in ' + delta2human( fdelta, 3 )
print 'Shutdown in ' + human( future )
print ''
if __name__ == "__main__": test()
if __name__ == "__main__":
from test_ago import test_output
test_output()

27
test_ago.py Normal file
View file

@ -0,0 +1,27 @@
from ago import human
from ago import delta2dict
from ago import delta2human
def test_output():
"""Test and example usage"""
from datetime import datetime
from datetime import timedelta
present = datetime.now()
past = present - timedelta( 492, 58711, 45 ) # days, secs, ms
future = present + timedelta( 2, 12447, 963 ) # days, secs, ms
pdelta = present - past
fdelta = future - present
print '\nTesting past:\n'
print delta2dict( pdelta )
print 'Commented ' + delta2human( pdelta, 3 ) + ' ago'
print 'Commented ' + human( past ) + ' ago'
print '\nTesting future:\n'
print delta2dict( fdelta )
print 'Shutdown in ' + delta2human( fdelta, 3 )
print 'Shutdown in ' + human( future )
print ''