fix tests

This commit is contained in:
Mathieu Le Marec - Pasquet 2014-01-29 20:51:35 +01:00
parent 0ab6051df7
commit 4b8322cede
6 changed files with 27 additions and 21 deletions

View File

@ -7,10 +7,8 @@ python:
# matrix:
install:
- python bootstrap.py
- python -V
- 'echo $SHELL'
- if [ x"$(python -V)" = x"Python 4"* ];then bin/buidout -c py3.cfg;fi
- if [ x"$(python -V)" = x"Python 2"* ];then bin/buidout;fi
- python bootstrap.py
- 'if [[ x"$(python -V 2>&1)" == x"Python 3"* ]];then ./bin/buildout -c py3.cfg;fi'
- 'if [[ x"$(python -V 2>&1)" == x"Python 2"* ]];then ./bin/buildout;fi'
script: bin/test

View File

@ -3,7 +3,6 @@ package-name = croniter
develop = .
versions=versions
parts =
# tox
scripts
omelette
coverage

View File

@ -3,3 +3,7 @@ extends=buildout.cfg
parts-=
omelette
code-analysis
[scripts]
eggs-=
ipython
zest.releaser

View File

@ -46,8 +46,6 @@ setup(
extras_require={
'test': [
"pytz",
'plone.testing',
"zope.interface",
],
},
)

View File

@ -93,17 +93,17 @@ class croniter(object):
raise ValueError(
"[{0}] is not acceptable".format(expr_format))
#low, high, step = map(int, [low, high, step])
#e_list += range(low, high + 1, step)
low, high, step = map(int, [low, high, step])
e_list += range(low, high + 1, step)
# other solution
try:
for j in xrange(int(low), int(high) + 1):
if j % int(step) == 0:
e_list.append(j)
except NameError:
for j in range(int(low), int(high) + 1):
if j % int(step) == 0:
e_list.append(j)
#try:
# for j in xrange(int(low), int(high) + 1):
# if j % int(step) == 0:
# e_list.append(j)
#except NameError:
# for j in range(int(low), int(high) + 1):
# if j % int(step) == 0:
# e_list.append(j)
else:
if not star_or_int_re.search(t):
t = self.ALPHACONV[i][t.lower()]

View File

@ -92,9 +92,13 @@ class CroniterTest(base.TestCase):
base = datetime(2010, 2, 24, 12, 9)
itr = croniter('0 0 */3 * *', base)
n1 = itr.get_next(datetime)
self.assertEqual(n1.day, 27)
# 1 4 7 10 13 16 19 22 25 28
self.assertEqual(n1.day, 25)
n2 = itr.get_next(datetime)
self.assertEqual(n2.day, 3)
self.assertEqual(n2.day, 28)
n3 = itr.get_next(datetime)
self.assertEqual(n3.day, 1)
self.assertEqual(n3.month, 3)
# test leap year
base = datetime(1996, 2, 27)
@ -254,9 +258,12 @@ class CroniterTest(base.TestCase):
base = datetime(2012, 2, 24)
itr = croniter('5 0 */2 * *', base)
n1 = itr.get_prev(datetime)
self.assertEqual(n1.day, 22)
self.assertEqual(n1.hour, 0)
self.assertEqual(n1.minute, 5)
self.assertEqual(n1.month, 2)
# month starts from 1, 3 .... then 21, 23
# so correct is not 22 but 23
self.assertEqual(n1.day, 23)
def testBug2(self):
base = datetime(2012, 1, 1, 0, 0)