[Checkins] SVN: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/ modernized test setup
Reinout van Rees
reinout at vanrees.org
Tue Jun 16 09:13:09 EDT 2009
Log message for revision 101077:
modernized test setup
Changed:
U z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt
U z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/tests.py
-=-
Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt 2009-06-16 12:57:40 UTC (rev 101076)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/README.txt 2009-06-16 13:13:09 UTC (rev 101077)
@@ -87,7 +87,7 @@
... 'WARNING="Everything below is added by bla bla',
... 'BUILDOUT=my/buildout',
... '@reboot echo nothing happens']
- >>> print c # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
+ >>> print c
WARNING="Everything below is added by bla bla
BUILDOUT=my/buildout
@reboot echo nothing happens
@@ -162,7 +162,8 @@
... ''' % ( { 'crontest': crontestfile } ))
>>> import os
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Installing foo.
<BLANKLINE>
@@ -175,11 +176,11 @@
>>> '# @reboot\techo nothing happens' in c.crontab
True
- >>> print c # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
+ >>> print c
<BLANKLINE>
- # Generated by .../sample-buildout [foo]
+ # Generated by /sample-buildout [foo]
# @reboot echo nothing happens
- # END .../sample-buildout [foo]
+ # END /sample-buildout [foo]
<BLANKLINE>
Uninstall the recipe:
@@ -189,7 +190,8 @@
... [buildout]
... parts =
... ''' % ( { 'crontest': crontestfile } ))
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Uninstalling foo.
Running uninstall recipe.
<BLANKLINE>
@@ -225,21 +227,22 @@
... readcrontab = cat %(crontest)s
... writecrontab = cat >%(crontest)s
... ''' % ( { 'crontest': crontestfile } ))
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Installing foo.
Installing bar.
<BLANKLINE>
>>> c.read_crontab()
- >>> print c # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
+ >>> print c
<BLANKLINE>
- # Generated by .../sample-buildout [foo]
+ # Generated by /sample-buildout [foo]
# @reboot echo nothing happens
- # END .../sample-buildout [foo]
+ # END /sample-buildout [foo]
<BLANKLINE>
<BLANKLINE>
- # Generated by .../sample-buildout [bar]
+ # Generated by /sample-buildout [bar]
# @reboot echo something happens
- # END .../sample-buildout [bar]
+ # END /sample-buildout [bar]
<BLANKLINE>
Uninstalling also works fine
@@ -249,7 +252,8 @@
... [buildout]
... parts =
... ''' % ( { 'crontest': crontestfile } ))
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Uninstalling bar.
Running uninstall recipe.
Uninstalling foo.
@@ -277,7 +281,8 @@
... ''' % ( { 'crontest': crontestfile } ))
>>> import os
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Installing foo.
<BLANKLINE>
>>> c.crontab = []
@@ -287,7 +292,8 @@
... [buildout]
... parts =
... ''' % ( { 'crontest': crontestfile } ))
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Uninstalling foo.
Running uninstall recipe.
foo: WARNING: Did not find a crontab-entry during uninstall; please check manually if everything was removed correctly
@@ -309,7 +315,8 @@
... ''' % ( { 'crontest': crontestfile } ))
>>> import os
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Installing foo.
<BLANKLINE>
>>> c.crontab = ['WARNING="Everything below is added by bla bla"',
@@ -321,7 +328,8 @@
... [buildout]
... parts =
... ''' % ( { 'crontest': crontestfile } ))
- >>> print system(os.path.join('bin', 'buildout'))
+ >>> print 'start', system(buildout)
+ start...
Uninstalling foo.
Running uninstall recipe.
<BLANKLINE>
Modified: z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/tests.py
===================================================================
--- z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/tests.py 2009-06-16 12:57:40 UTC (rev 101076)
+++ z3c.recipe.usercrontab/trunk/src/z3c/recipe/usercrontab/tests.py 2009-06-16 13:13:09 UTC (rev 101077)
@@ -8,25 +8,52 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
+import unittest
+import zc.buildout.tests
import zc.buildout.testing
-
-import unittest
-import zope.testing
from zope.testing import doctest, renormalizing
-from z3c.recipe.usercrontab import UserCrontabManager
-usercrontab = UserCrontabManager(identifier='test')
+optionflags = (doctest.ELLIPSIS
+ |doctest.NORMALIZE_WHITESPACE
+ )
+
def setUp(test):
zc.buildout.testing.buildoutSetUp(test)
- usercrontab.read_crontab() # Store current user's real crontab.
+
+ # Install the recipe in develop mode
zc.buildout.testing.install_develop('z3c.recipe.usercrontab', test)
+ # Install any other recipes that should be available in the tests
+ # Store current user's real crontab.
+ from z3c.recipe.usercrontab import UserCrontabManager
+ test.usercrontab = UserCrontabManager(identifier='test')
+ test.usercrontab.read_crontab()
+
+
def tearDown(test):
zc.buildout.testing.buildoutTearDown(test)
- usercrontab.write_crontab() # Restore current user's real crontab.
+ # Restore current user's real crontab.
+ test.usercrontab.write_crontab()
+
def test_suite():
- return unittest.TestSuite(doctest.DocFileSuite('README.txt', setUp=setUp,
- tearDown=tearDown))
+ suite = unittest.TestSuite((
+ doctest.DocFileSuite(
+ 'README.txt',
+ setUp=setUp,
+ tearDown=tearDown,
+ optionflags=optionflags,
+ checker=renormalizing.RENormalizing([
+ # If want to clean up the doctest output you
+ # can register additional regexp normalizers
+ # here. The format is a two-tuple with the RE
+ # as the first item and the replacement as the
+ # second item, e.g.
+ # (re.compile('my-[rR]eg[eE]ps'), 'my-regexps')
+ zc.buildout.testing.normalize_path,
+ ]),
+ ),
+ ))
+ return suite
More information about the Checkins
mailing list