switch over nose for tests

This commit is contained in:
Mathieu Le Marec - Pasquet 2014-01-29 13:58:16 +01:00
parent 61f0b322de
commit f525f062d7
6 changed files with 25 additions and 135 deletions

3
.gitignore vendored
View File

@ -1,4 +1,7 @@
*app.pyc
distribute*
.tox
tox.ini
t/
eggs
\.*.cfg

View File

@ -3,11 +3,12 @@ package-name = croniter
develop = .
versions=versions
parts =
# tox
scripts
omelette
test
coverage
report
test
report-xml
code-analysis
extensions =
@ -28,36 +29,18 @@ recipe=zc.recipe.egg
eggs = ${buildout:eggs}
zest.releaser
ipython
interpreter = scripts
scripts =
ipython
croniter
fullrelease
paster
tox
nose
nosetests
fullrelease
lasttagdiff
lasttaglog
longtest
postrelease
prerelease
release
rst2html.py
rst2latex.py
rst2man.py
rst2odt_prepstyles.py
rst2odt.py
rst2pseudoxml.py
rst2s5.py
rst2xetex.py
rst2xml.py
rstpep2html.py
interpreter = scripts
[test]
recipe = zc.recipe.testrunner
defaults = ['-v', '-s', '${buildout:package-name}']
eggs = ${buildout:test-eggs}
recipe=zc.recipe.egg
eggs = ${scripts:eggs}
croniter[test]
arguments= ['croniter']
scripts=test
entry-points=
test=nose:run_exit
[coverage]
recipe = zc.recipe.egg
@ -134,6 +117,3 @@ zope.browser = 2.0.2
zope.component = 4.1.0
zope.configuration = 4.0.2

View File

@ -1,19 +0,0 @@
from plone.testing.layer import Layer as Base
class Layer(Base):
defaultBases = tuple()
class IntegrationLayer(Layer):
"""."""
class FunctionnalLayer(IntegrationLayer):
"""."""
CRONITER_FIXTURE = Layer()
CRONITER_INTEGRATION_TESTING = IntegrationLayer()
CRONITER_FUNCTIONAL_TESTING = FunctionnalLayer()

View File

@ -1,31 +1,12 @@
import unittest2 as unittest
from croniter.testing import (
CRONITER_FIXTURE as UNIT_TESTING,
CRONITER_INTEGRATION_TESTING as INTEGRATION_TESTING,
CRONITER_FUNCTIONAL_TESTING as FUNCTIONAL_TESTING,
)
try:
import unittest2 as unittest
except ImportError:
import unittest
class TestCase(unittest.TestCase):
"""We use this base class for all the tests in this package.
'''
We use this base class for all the tests in this package.
If necessary, we can put common utility or setup code in here.
"""
layer = UNIT_TESTING
def setUp(self):
super(TestCase, self).setUp()
class IntegrationTestCase(TestCase):
"""Integration base TestCase."""
layer = INTEGRATION_TESTING
class FunctionalTestCase(TestCase):
"""Functionnal base TestCase."""
layer = FUNCTIONAL_TESTING
'''
# vim:set ft=python:

View File

@ -10,6 +10,7 @@ from croniter.tests import base
class CroniterTest(base.TestCase):
def testSecond(self):
base = datetime(2012, 4, 6, 13, 26, 10)
itr = croniter('*/1 * * * * *', base)
@ -258,7 +259,7 @@ class CroniterTest(base.TestCase):
self.assertEqual(n1.minute, 5)
def testBug2(self):
base = datetime(2012, 1, 1, 00, 00)
base = datetime(2012, 1, 1, 0, 0)
iter = croniter('0 * * 3 *', base)
n1 = iter.get_next(datetime)
self.assertEqual(n1.year, base.year)
@ -334,7 +335,7 @@ class CroniterTest(base.TestCase):
self.assertEqual(prev1.minute, 59)
def testPreviousDay(self):
base = datetime(2012, 6, 27, 00, 15)
base = datetime(2012, 6, 27, 0, 15)
itr = croniter('* * 26 * *', base)
prev1 = itr.get_prev(datetime)
self.assertEqual(prev1.year, base.year)
@ -344,7 +345,7 @@ class CroniterTest(base.TestCase):
self.assertEqual(prev1.minute, 59)
def testPreviousMonth(self):
base = datetime(2012, 6, 18, 00, 15)
base = datetime(2012, 6, 18, 0, 15)
itr = croniter('* * * 5 *', base)
prev1 = itr.get_prev(datetime)
self.assertEqual(prev1.year, base.year)

View File

@ -1,56 +0,0 @@
"""
Launching all doctests in the tests directory using:
- the base layer in testing.py
"""
# GLOBALS avalaible in doctests
# IMPORT/DEFINE objects there or inside ./user_globals.py (better)
# globals from the testing product are also available.
# example:
# from for import bar
# and in your doctests, you can do:
# >>> bar.something
from croniter.testing import CRONITER_FUNCTIONAL_TESTING as FUNCTIONAL_TESTING
import unittest2 as unittest
import glob
import os
import logging
import doctest
from plone.testing import layered
optionflags = (doctest.ELLIPSIS
| doctest.NORMALIZE_WHITESPACE
| doctest.REPORT_ONLY_FIRST_FAILURE)
def test_suite():
"""."""
logger = logging.getLogger('croniter')
cwd = os.path.dirname(__file__)
files = []
try:
files = glob.glob(os.path.join(cwd, '*txt'))
files += glob.glob(os.path.join(cwd, '*rst'))
except Exception:
logger.warn('No doctests for croniter')
suite = unittest.TestSuite()
globs = globals()
for s in files:
suite.addTests([
layered(
doctest.DocFileSuite(
s,
globs=globs,
module_relative=False,
optionflags=optionflags,
),
layer=FUNCTIONAL_TESTING
),
])
return suite
#