Permalink
Browse files

start of tests

  • Loading branch information...
djay committed Sep 15, 2012
1 parent d684fa9 commit 4b0a46e5e57bb218b445ad2ac4aed274ecb35cf1
View
@@ -18,13 +18,13 @@
use the -c option to specify an alternate configuration file.
"""
-import os, shutil, sys, tempfile, textwrap, urllib, urllib2, subprocess
+import os, shutil, sys, tempfile, urllib, urllib2, subprocess
from optparse import OptionParser
if sys.platform == 'win32':
def quote(c):
if ' ' in c:
- return '"%s"' % c # work around spawn lamosity on windows
+ return '"%s"' % c # work around spawn lamosity on windows
else:
return c
else:
@@ -57,13 +57,13 @@ def quote(c):
# out any namespace packages from site-packages that might have been
# loaded by .pth files.
clean_path = sys.path[:]
-import site
+import site # imported because of its side effects
sys.path[:] = clean_path
for k, v in sys.modules.items():
if k in ('setuptools', 'pkg_resources') or (
hasattr(v, '__path__') and
- len(v.__path__)==1 and
- not os.path.exists(os.path.join(v.__path__[0],'__init__.py'))):
+ len(v.__path__) == 1 and
+ not os.path.exists(os.path.join(v.__path__[0], '__init__.py'))):
# This is a namespace package. Remove it.
sys.modules.pop(k)
@@ -72,10 +72,11 @@ def quote(c):
setuptools_source = 'http://peak.telecommunity.com/dist/ez_setup.py'
distribute_source = 'http://python-distribute.org/distribute_setup.py'
+
# parsing arguments
def normalize_to_url(option, opt_str, value, parser):
if value:
- if '://' not in value: # It doesn't smell like a URL.
+ if '://' not in value: # It doesn't smell like a URL.
value = 'file://%s' % (
urllib.pathname2url(
os.path.abspath(os.path.expanduser(value))),)
@@ -110,7 +111,7 @@ def normalize_to_url(option, opt_str, value, parser):
help=("Specify a URL or file location for the setup file. "
"If you use Setuptools, this will default to " +
setuptools_source + "; if you use Distribute, this "
- "will default to " + distribute_source +"."))
+ "will default to " + distribute_source + "."))
parser.add_option("--download-base", action="callback", dest="download_base",
callback=normalize_to_url, nargs=1, type="string",
help=("Specify a URL or directory for downloading "
@@ -133,7 +134,9 @@ def normalize_to_url(option, opt_str, value, parser):
help=("Specify the path to the buildout configuration "
"file to be used."))
-options, args = parser.parse_args()
+options, orig_args = parser.parse_args()
+
+args = []
# if -c was provided, we push it back into args for buildout's main function
if options.config_file is not None:
@@ -152,11 +155,10 @@ def normalize_to_url(option, opt_str, value, parser):
if options.accept_buildout_test_releases:
args.append('buildout:accept-buildout-test-releases=true')
-args.append('bootstrap')
try:
import pkg_resources
- import setuptools # A flag. Sometimes pkg_resources is installed alone.
+ import setuptools # A flag. Sometimes pkg_resources is installed alone.
if not hasattr(pkg_resources, '_distribute'):
raise ImportError
except ImportError:
@@ -211,6 +213,7 @@ def normalize_to_url(option, opt_str, value, parser):
# Figure out the most recent final version of zc.buildout.
import setuptools.package_index
_final_parts = '*final-', '*final'
+
def _final_version(parsed_version):
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
@@ -242,7 +245,7 @@ def _final_version(parsed_version):
if is_jython:
import subprocess
exitcode = subprocess.Popen(cmd, env=env).wait()
-else: # Windows prefers this, apparently; otherwise we would prefer subprocess
+else: # Windows prefers this, apparently; otherwise we would prefer subprocess
exitcode = os.spawnle(*([os.P_WAIT, sys.executable] + cmd + [env]))
if exitcode != 0:
sys.stdout.flush()
@@ -255,6 +258,9 @@ def _final_version(parsed_version):
ws.add_entry(eggs_dir)
ws.require(requirement)
import zc.buildout.buildout
-zc.buildout.buildout.main(args)
-if not options.eggs: # clean up temporary egg directory
+if orig_args:
+ # run buildout with commands passed to bootstrap.py, then actually bootstrap
+ zc.buildout.buildout.main(args + orig_args)
+zc.buildout.buildout.main(args + ['bootstrap'])
+if not options.eggs: # clean up temporary egg directory
shutil.rmtree(eggs_dir)
View
@@ -1,18 +1,20 @@
+# Copy to buildout.cfg and uncomment one config
[buildout]
-extends =
- http://svn.plone.org/svn/collective/buildout/plonetest/plone-4.1.x.cfg
+develop =
+ .
-package-name = collective.listingviews
+extends =
+# conf/test-3.3.x.cfg
+ conf/test-4.2.x.cfg
-parts += omelette
+[plone]
+eggs +=
+ collective.listingviews
+ sauna.reload
+zope-conf-additional = %import sauna.reload
[test]
recipe = zc.recipe.testrunner
-eggs =
- ${instance:eggs}
- collective.listingviews [test]
-defaults = ['-s', '${buildout:package-name}']
-
-[omelette]
-recipe = collective.recipe.omelette
-eggs = ${instance:eggs}
+eggs =
+ ${plone:eggs}
+ plone.app.collection
View
@@ -0,0 +1,6 @@
+[buildout]
+extends = http://build.pythonpackages.com/buildout/plone/3.3.x-dev
+
+[plone]
+#eggs += mr.migrator
+eggs += funnelweb
View
@@ -0,0 +1,67 @@
+[buildout]
+allow-hosts =
+ dist.plone.org
+ pypi.python.org
+extends = http://dist.plone.org/release/4.1-latest/versions.cfg
+dump-picked-versions-file = picked.cfg
+exec-sitecustomize = false
+extensions =
+ mr.developer
+ buildout.dumppickedversions
+find-links = http://dist.plone.org/thirdparty/elementtree-1.2.7-20070827-preview.zip
+sources = sources
+sources-dir = ${buildout:directory}/src
+#include-site-packages = false
+parts =
+ instance
+ test
+develop = .
+versions = versions
+
+
+[test]
+recipe = zc.recipe.testrunner
+eggs =
+ pretaweb.metadata [tests]
+ z3c.autoinclude
+ zc.recipe.egg
+
+
+[lxml]
+recipe = z3c.recipe.staticlxml
+egg = lxml == 2.2.8
+
+[PIL]
+# Build egg with Chris McDonough's custom packaging of setuptools-compatibile PIL
+# http://article.gmane.org/gmane.comp.web.zope.devel/13999
+recipe = zc.recipe.egg
+egg = PIL==1.1.6
+find-links = http://dist.repoze.org/PIL-1.1.6.tar.gz
+
+[instance]
+recipe = plone.recipe.zope2instance
+debug-mode = on
+verbose-security = on
+user = admin:admin
+eggs =
+ ${PIL:egg}
+ Plone
+ ${lxml:egg}
+ pretaweb.metadata
+ plone.reload
+ ipdb
+
+zcml-eggs =
+
+[mkrelease]
+recipe = zc.recipe.egg
+eggs =
+ jarn.mkrelease
+ collective.checkdocs
+
+[sources]
+
+[versions]
+distribute = 0.6.19
+zc.buildout = 1.5.2
+zc.recipe.egg = 1.3.2
View
@@ -0,0 +1,55 @@
+[buildout]
+allow-hosts =
+ *.plone.org
+ *.python.org
+ *.sourceforge.net
+extensions =
+ buildout.bootstrap
+ buildout.dumppickedversions
+ mr.developer
+extends = http://dist.plone.org/release/4.2rc2/versions.cfg
+find-links =
+ http://dist.plone.org/thirdparty/elementtree-1.2.7-20070827-preview.zip
+ http://downloads.sourceforge.net/project/docutils/docutils/0.9/docutils-0.9.tar.gz
+parts =
+ plone
+ omelette
+ zopepy
+ test
+versions = versions
+auto-checkout = *
+
+[omelette]
+recipe = collective.recipe.omelette
+eggs = ${plone:eggs}
+
+
+[plone]
+recipe = plone.recipe.zope2instance
+verbose-security = on
+eggs =
+ Pillow
+ Plone
+ zope2_bootstrap
+ Products.DocFinderTab
+ Products.FSDump
+# plone.app.debugtoolbar
+user = admin:admin
+zcml = zope2_bootstrap
+
+
+
+[zopepy]
+recipe = zc.recipe.egg
+eggs = ${plone:eggs}
+interpreter = zopepy
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = ${plone:eggs}
+
+
+[versions]
+distribute = 0.6.27
+zc.buildout = 1.5.2
+
@@ -0,0 +1,22 @@
+import unittest2 as unittest
+import doctest
+from collective.listingviews.testing import\
+ COLLECTIVE_LISTINGVIEWS_INTEGRATION_TESTING
+
+
+
+OPTIONFLAGS = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+# seltest = doctest.DocFileSuite('selenium.rst', optionflags=OPTIONFLAGS)
+ # Run selenium tests on level 2, as it requires a correctly configured
+ # Firefox browser
+# seltest.level = 2
+ layer = COLLECTIVE_LISTINGVIEWS_INTEGRATION_TESTING
+ suite.addTests([
+ doctest.DocFileSuite('tests/listingviews.rst', optionflags=OPTIONFLAGS, globs=dict(layer=layer)),
+ ])
+ suite.layer = COLLECTIVE_LISTINGVIEWS_INTEGRATION_TESTING
+ return suite
@@ -1 +0,0 @@
-#
@@ -0,0 +1,13 @@
+
+>>> from plone.testing.z2 import Browser
+>>> from plone.app.testing import TEST_USER_ID, TEST_USER_NAME, TEST_USER_PASSWORD, setRoles, login
+>>> portal = layer['portal']
+>>> browser = Browser(portal)
+>>> portalURL = portal.absolute_url()
+>>> browser.open(portalURL)
+
+>>> browser.open(portal.absolute_url()+'/@@listingviews_controlpanel')
+
+>>> browser.getControl(name='__ac_name').value = TEST_USER_NAME
+>>> browser.getControl(name='__ac_password').value = TEST_USER_PASSWORD
+>>> browser.getControl(name='submit').click()
@@ -24,3 +24,4 @@ def test_product_is_installed(self):
installed = [p['id'] for p in self.qi_tool.listInstalledProducts()]
self.assertTrue(pid in installed,
'package appears not to have been installed')
+

0 comments on commit 4b0a46e

Please sign in to comment.