From 4b8322cedeb5a4a6c7cbb3721d985045113b0f70 Mon Sep 17 00:00:00 2001 From: Mathieu Le Marec - Pasquet Date: Wed, 29 Jan 2014 20:51:35 +0100 Subject: [PATCH] fix tests --- .travis.yml | 8 +++----- buildout.cfg | 1 - py3.cfg | 4 ++++ setup.py | 2 -- src/croniter/croniter.py | 20 ++++++++++---------- src/croniter/tests/test_croniter.py | 13 ++++++++++--- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae05d34..0055a11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/buildout.cfg b/buildout.cfg index 908b3d2..0cdd8a2 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -3,7 +3,6 @@ package-name = croniter develop = . versions=versions parts = -# tox scripts omelette coverage diff --git a/py3.cfg b/py3.cfg index 939e820..2bd685f 100644 --- a/py3.cfg +++ b/py3.cfg @@ -3,3 +3,7 @@ extends=buildout.cfg parts-= omelette code-analysis +[scripts] +eggs-= + ipython + zest.releaser diff --git a/setup.py b/setup.py index 24d6dbd..584eb73 100644 --- a/setup.py +++ b/setup.py @@ -46,8 +46,6 @@ setup( extras_require={ 'test': [ "pytz", - 'plone.testing', - "zope.interface", ], }, ) diff --git a/src/croniter/croniter.py b/src/croniter/croniter.py index 5dc170e..fc5a740 100644 --- a/src/croniter/croniter.py +++ b/src/croniter/croniter.py @@ -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()] diff --git a/src/croniter/tests/test_croniter.py b/src/croniter/tests/test_croniter.py index a159582..d491842 100644 --- a/src/croniter/tests/test_croniter.py +++ b/src/croniter/tests/test_croniter.py @@ -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)