[Checkins] SVN: grokproject/trunk/tests more test cleanups and fixing tests of "GrokExample2"
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Mon Apr 19 12:13:29 EDT 2010
Log message for revision 111121:
more test cleanups and fixing tests of "GrokExample2"
Changed:
U grokproject/trunk/tests.py
U grokproject/trunk/tests_paste.txt
-=-
Modified: grokproject/trunk/tests.py
===================================================================
--- grokproject/trunk/tests.py 2010-04-19 16:12:09 UTC (rev 111120)
+++ grokproject/trunk/tests.py 2010-04-19 16:13:28 UTC (rev 111121)
@@ -19,15 +19,16 @@
from zope.testing import doctest
current_dir = os.path.abspath(os.path.dirname(__file__))
+shorttestfile = os.path.join(os.path.dirname(__file__), 'shorttests')
+## FIXME - check for other platforms
+MUST_CLOSE_FDS = not sys.platform.startswith('win')
+
def rmdir(*args):
dirname = os.path.join(*args)
if os.path.isdir(dirname):
shutil.rmtree(dirname)
-## FIXME - check for other platforms
-MUST_CLOSE_FDS = not sys.platform.startswith('win')
-
def read_sh(command, input=None):
p = subprocess.Popen(command,
stdin=subprocess.PIPE,
@@ -54,7 +55,6 @@
dirname = os.path.join(*args)
os.chdir(dirname)
-
def cat(*args):
filename = os.path.join(*args)
if os.path.isfile(filename):
@@ -66,56 +66,19 @@
filename = os.path.join(*args)
open(filename, 'w').write(kwargs.get('data',''))
-def shorttests(show_message=False):
- shorttestfile = os.path.join(
- os.path.dirname(__file__), 'shorttests')
- if not show_message:
- return os.path.exists(shorttestfile)
- if os.path.exists(shorttestfile):
- print
- print "WARNING: running shorttests."
- print " This reduces the runtime of testruns by making use of"
- print " a once filled eggs directory."
- print " If you want clean test runs with an empty eggs directory,"
- print " remove the file"
- print " " + shorttestfile
- print " Running shorttests might lead to failing tests. Please run"
- print " the full tests before submitting code."
- print
- else:
- print
- print "NOTE: running full tests."
- print " If you want to reuse a prefilled eggs directory between"
- print " test runs (which dramatically reduces runtime), create a"
- print " file "
- print " " + shorttestfile
- print " and rerun the tests."
- print
+def shorttests():
return os.path.exists(shorttestfile)
def maybe_mkdir(path):
- """Create a directory `path` conditionally.
-
- If the dir already exists and `shorttest()` is ``True`` we leave
- the directory untouched.
-
- Otherwise any old file/directory with path `path` is removed and
- recreated.
- """
if shorttests() and os.path.isdir(path):
return
rmdir(path)
os.makedirs(path)
def maybe_rmdir(path):
- """Remove a directory conditionally.
-
- If `shorttest()` is True, we do not remove the directory.
- """
if shorttests() and os.path.isdir(path):
return
rmdir(path)
-
def setup(test):
eggsdir = os.path.join(tempfile.gettempdir(), 'grokproject-test-eggs')
@@ -130,7 +93,7 @@
def doc_suite(package_dir):
"""Returns a test suite"""
suite = []
- flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
+ flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
doctest.REPORT_ONLY_FIRST_FAILURE)
if package_dir not in sys.path:
@@ -150,16 +113,36 @@
}
for test in tests:
- suite.append(doctest.DocFileSuite(test, optionflags=flags,
- globs=globs,
- setUp=setup,
- tearDown=teardown,
- module_relative=False))
+ suite.append(doctest.DocFileSuite(
+ test, optionflags=flags, globs=globs, setUp=setup, tearDown=teardown,
+ module_relative=False))
return unittest.TestSuite(suite)
+def show_shorttests_message():
+ if shorttests():
+ print
+ print 'WARNING: running shorttests.'
+ print
+ print ' This reduces the runtime of testruns by making use of'
+ print ' a once filled eggs directory.'
+ print ' If you want clean test runs with an empty eggs directory,'
+ print ' remove the file "' + shorttestfile + '".'
+ print
+ print ' Running shorttests might lead to failing tests. Please run'
+ print ' the full tests before submitting code.'
+ print
+ else:
+ print
+ print 'NOTE: running full tests.'
+ print
+ print ' If you want to reuse a prefilled eggs directory between'
+ print ' test runs (which dramatically reduces runtime), create a'
+ print ' file "' + shorttestfile + '" and rerun the tests.'
+ print
+
def test_suite():
"""returns the test suite"""
- shorttests(show_message=True)
+ show_shorttests_message()
return doc_suite(current_dir)
if __name__ == '__main__':
Modified: grokproject/trunk/tests_paste.txt
===================================================================
--- grokproject/trunk/tests_paste.txt 2010-04-19 16:12:09 UTC (rev 111120)
+++ grokproject/trunk/tests_paste.txt 2010-04-19 16:13:28 UTC (rev 111121)
@@ -14,10 +14,10 @@
>>> opts = ['--user=a', '--passwd=a', '--eggs-dir=' + eggsdir]
>>> grokversion = ['--grokversion=1.1rc1']
>>> sh(executable + opts + grokversion + ['GrokExample'])
- ['...grokproject', '--user=a', '--passwd=a', '--eggs-dir=...grokexample-eggs',
+ ['...grokproject', '--user=a', '--passwd=a',
+ '--eggs-dir=...grokproject-test-eggs',
'--grokversion=1.1rc1', 'GrokExample']
- Creating directory ./GrokExample
- Downloading zc.buildout...
+ Creating directory ./GrokExample...
Invoking zc.buildout...
*************** PICKED VERSIONS ****************
[versions]
@@ -31,6 +31,7 @@
>>> print open(os.path.join(package_dir, 'buildout.cfg')).read()
[buildout]
extends = http://grok.zope.org/releaseinfo/1.1rc1/versions.cfg
+ extends-cache = cache
find-links = http://grok.zope.org/releaseinfo/1.1rc1/eggs/
...
@@ -90,7 +91,7 @@
>>> len(os.listdir(eggsdir)) > 100
True
-The extends-cache directive results in cached versions of the referenced
+The extends-cache directive results in cached versions of the referenced
buildout files to support offline building. We know what the filename of the
cached versions file for 1.1rc1 will look like:
@@ -108,7 +109,7 @@
The password given is stored SHA1 encoded::
- >>> site_zcml_in = os.path.join(package_dir, 'etc',
+ >>> site_zcml_in = os.path.join(package_dir, 'etc',
... 'site.zcml.in')
>>> print open(site_zcml_in, 'rb').read()
<configure xmlns="http://namespaces.zope.org/zope"
@@ -240,15 +241,19 @@
>>> print output
Develop: ...
Updating app.
+ ...
Updating site_zcml.
Updating zope_conf.
Updating debug_ini.
Updating deploy_ini.
Updating i18n.
i18n: setting up i18n tools
+ ...
Updating mkdirs.
Updating test.
+ ...
Updating zpasswd.
+ ...
Updating data.
Updating log.
*************** PICKED VERSIONS ****************
@@ -258,30 +263,33 @@
<BLANKLINE>
We can influence the version of grok to be installed by using the
-``grokversion`` parameter.
+``grokversion`` parameter.
>>> cd(testdir)
>>> package_dir = os.path.join(testdir, 'GrokExample2')
>>> grokversion = ['--grokversion=1.1a2']
- >>> # WARNING: We know that running the buildout of grok 1.1a2 has a
- >>> # buildout failure. That's OK for this test, as we want to show
- >>> # that we can point to a different version.
+
+ >>> # WARNING: We know that running the buildout of grok 1.1a2 has
+ >>> # a buildout failure. That's OK for this test, as we just want
+ >>> # to show that we can point to a different version.
+
>>> sh(executable + opts + grokversion + ['GrokExample2'])
- ['...grokproject', '--user=a', '--passwd=a', '--eggs-dir=...grokexample-eggs',
+ ['...grokproject', '--user=a', '--passwd=a',
+ '--eggs-dir=...grokproject-test-eggs',
'--grokversion=1.1a2', 'GrokExample2']
Creating directory ./GrokExample2
- Downloading zc.buildout...
- Invoking zc.buildout...
- *************** PICKED VERSIONS ****************
- [versions]
- ...
- *************** /PICKED VERSIONS ***************
+ While:
+ Installing app.
+ Error: There is a version conflict.
+ We already have: zope.publisher 3.9.3
+ but zope.app.container 3.8.2 requires 'zope.publisher>=3.12'...
>>> print open(os.path.join(package_dir, 'buildout.cfg')).read()
[buildout]
- extends = http://grok.zope.org/releaseinfo/grok-1.1a2.cfg
+ extends = http://grok.zope.org/releaseinfo/1.1a2/versions.cfg
+ extends-cache = cache
+ find-links = http://grok.zope.org/releaseinfo/1.1a2/eggs/
...
>>> ls(os.path.join(package_dir, 'cache'))
- 6ac204ce415265b11b4a9a4701f2a04f
-
+ eb77a071fb78a2da37cbe18aff8b2a5a
More information about the checkins
mailing list