[Checkins] SVN: z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/ per flacoste review, clarify the intent and behavior of write_and_wait by renaming and adding a doc string. Also add a time.sleep.
Gary Poster
gary.poster at canonical.com
Tue Jul 14 09:59:05 EDT 2009
Log message for revision 101901:
per flacoste review, clarify the intent and behavior of write_and_wait by renaming and adding a doc string. Also add a time.sleep.
Changed:
U z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt
U z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/tests.py
-=-
Modified: z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt
===================================================================
--- z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt 2009-07-14 13:11:59 UTC (rev 101900)
+++ z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/README.txt 2009-07-14 13:59:05 UTC (rev 101901)
@@ -52,7 +52,7 @@
If you need to escape the ${...} pattern, you can do so by repeating the dollar
sign.
- >>> write_and_wait(sample_buildout, 'helloworld.txt.in',
+ >>> update_file(sample_buildout, 'helloworld.txt.in',
... """
... Hello world! The double $${dollar-sign} escapes!
... """)
@@ -66,7 +66,7 @@
Note that dollar signs alone, without curly braces, are not parsed.
- >>> write_and_wait(sample_buildout, 'helloworld.txt.in',
+ >>> update_file(sample_buildout, 'helloworld.txt.in',
... """
... $Hello $$world! $$$profit!
... """)
Modified: z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/tests.py
===================================================================
--- z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/tests.py 2009-07-14 13:11:59 UTC (rev 101900)
+++ z3c.recipe.filetemplate/branches/gary-support-system-python/z3c/recipe/filetemplate/tests.py 2009-07-14 13:59:05 UTC (rev 101901)
@@ -13,14 +13,21 @@
##############################################################################
import os
+import time
import zc.buildout.testing
import zc.buildout.tests
from zope.testing import doctest
-def write_and_wait(dir, *args):
+def update_file(dir, *args):
+ """Update a file.
+
+ Make sure that the mtime of the file is updated so that buildout notices
+ the changes. The resolution of mtime is system dependent, so we keep
+ trying to write until mtime has actually changed."""
path = os.path.join(dir, *(args[:-1]))
original = os.stat(path).st_mtime
while os.stat(path).st_mtime == original:
+ time.sleep(0.2)
f = open(path, 'w')
f.write(args[-1])
f.flush()
@@ -29,7 +36,7 @@
def setUp(test):
zc.buildout.tests.easy_install_SetUp(test)
- test.globs['write_and_wait'] = write_and_wait
+ test.globs['update_file'] = update_file
zc.buildout.testing.install_develop('z3c.recipe.filetemplate', test)
def test_suite():
More information about the Checkins
mailing list