[Checkins] SVN: van.testing/trunk/ Add an option to have a zcml_features attribute on a zcml layer indicating the features to load when loading the zcml. Fixup changelog and prepare for release
Brian Sutherland
jinty at web.de
Wed Oct 28 09:52:24 EDT 2009
Log message for revision 105324:
Add an option to have a zcml_features attribute on a zcml layer indicating the features to load when loading the zcml. Fixup changelog and prepare for release
Changed:
U van.testing/trunk/CHANGES.txt
U van.testing/trunk/setup.py
U van.testing/trunk/van/testing/README.txt
U van.testing/trunk/van/testing/ftesting.zcml
U van.testing/trunk/van/testing/layer.py
U van.testing/trunk/van/testing/tests.py
A van.testing/trunk/van/testing/zcml_features.txt
-=-
Modified: van.testing/trunk/CHANGES.txt
===================================================================
--- van.testing/trunk/CHANGES.txt 2009-10-28 12:39:04 UTC (rev 105323)
+++ van.testing/trunk/CHANGES.txt 2009-10-28 13:52:24 UTC (rev 105324)
@@ -1,9 +1,15 @@
Changes
=======
-3.0.0 (unknown)
+3.0.0 (2009-10-28)
------------------
+- Add an option to have a zcml_features attribute on a zcml layer indicating
+ the features to load when loading the zcml.
+
+2.0.1 (2009-04-07)
+------------------
+
- Allow users to specify the domain and port of the wsgi_intercept_layer by
adding those attributes to the class.
- Fix testbrowser support a bit so that it performs more like
Modified: van.testing/trunk/setup.py
===================================================================
--- van.testing/trunk/setup.py 2009-10-28 12:39:04 UTC (rev 105323)
+++ van.testing/trunk/setup.py 2009-10-28 13:52:24 UTC (rev 105324)
@@ -23,7 +23,7 @@
)
setup(name="van.testing",
- version='2.0.2dev',
+ version='3.0.0',
license='ZPL 2.1',
url='http://pypi.python.org/pypi/van.testing',
author_email='zope-dev at zope.org',
Modified: van.testing/trunk/van/testing/README.txt
===================================================================
--- van.testing/trunk/van/testing/README.txt 2009-10-28 12:39:04 UTC (rev 105323)
+++ van.testing/trunk/van/testing/README.txt 2009-10-28 13:52:24 UTC (rev 105324)
@@ -58,3 +58,14 @@
>>> class ExampleNullLayer(ZCMLLayer):
... pass
>>> null_layer(ExampleNullLayer)
+
+This test runs in the layer van.testing.tests.ZCMLLayer, so we can get the
+"test" utility but not the test_extra utility (see zcml_features.txt for an
+example of a zcml layer with features):
+
+ >>> from zope.interface import Interface
+ >>> from zope.component import queryUtility
+ >>> queryUtility(Interface, name="test", default='None')
+ 'MARKER'
+ >>> queryUtility(Interface, name="test_extra", default='None')
+ 'None'
Modified: van.testing/trunk/van/testing/ftesting.zcml
===================================================================
--- van.testing/trunk/van/testing/ftesting.zcml 2009-10-28 12:39:04 UTC (rev 105323)
+++ van.testing/trunk/van/testing/ftesting.zcml 2009-10-28 13:52:24 UTC (rev 105324)
@@ -1,5 +1,6 @@
<configure
xmlns="http://namespaces.zope.org/zope"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
package="van.testing"
>
@@ -12,4 +13,10 @@
provides="zope.interface.Interface"
/>
+ <utility zcml:condition="have extra"
+ name="test_extra"
+ component=".tests.MARKER"
+ provides="zope.interface.Interface"
+ />
+
</configure>
Modified: van.testing/trunk/van/testing/layer.py
===================================================================
--- van.testing/trunk/van/testing/layer.py 2009-10-28 12:39:04 UTC (rev 105323)
+++ van.testing/trunk/van/testing/layer.py 2009-10-28 13:52:24 UTC (rev 105324)
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-from zope.configuration import xmlconfig
+from zope.configuration import config, xmlconfig
from zope.testing.cleanup import cleanUp
import wsgi_intercept
@@ -69,14 +69,20 @@
def zcml_layer(layer):
"""Sets up a class as a ZCMLLayer.
- The class can have 2 attributes:
+ The class can have 3 attributes:
zcml: The site zcml file to load.
+ zcml_features: A tuple of strings indicating the features to load.
allow_teardown: Whether to allow teardown of this layer.
Default: True
"""
def setUp(cls):
- context = xmlconfig.file(cls.zcml)
+ features = getattr(cls, 'zcml_features', ())
+ context = config.ConfigurationMachine()
+ xmlconfig.registerCommonDirectives(context)
+ for feature in features:
+ context.provideFeature(feature)
+ context = xmlconfig.file(cls.zcml, context=context)
layer.setUp = classmethod(setUp)
def tearDown(cls):
Modified: van.testing/trunk/van/testing/tests.py
===================================================================
--- van.testing/trunk/van/testing/tests.py 2009-10-28 12:39:04 UTC (rev 105323)
+++ van.testing/trunk/van/testing/tests.py 2009-10-28 13:52:24 UTC (rev 105324)
@@ -42,6 +42,11 @@
zcml = os.path.join(_HERE, 'ftesting.zcml')
zcml_layer(ZCMLLayer)
+class ZCMLExtraLayer:
+ zcml_features = ('extra',)
+ zcml = os.path.join(_HERE, 'ftesting.zcml')
+zcml_layer(ZCMLExtraLayer)
+
class FunctionalLayer(ZCMLLayer):
@classmethod
def make_application(cls):
@@ -51,9 +56,12 @@
def test_suite():
ftests = unittest.TestSuite([doctest.DocFileSuite('README.txt')])
ftests.layer = FunctionalLayer
+ extra_tests = unittest.TestSuite([doctest.DocFileSuite('zcml_features.txt')])
+ extra_tests.layer = ZCMLExtraLayer
if have_testbrowser:
ftests.addTest(doctest.DocFileSuite('testbrowser.txt'))
return unittest.TestSuite([
- ftests,
+ ftests,
+ extra_tests,
doctest.DocTestSuite('van.testing.layer'),
])
Added: van.testing/trunk/van/testing/zcml_features.txt
===================================================================
--- van.testing/trunk/van/testing/zcml_features.txt (rev 0)
+++ van.testing/trunk/van/testing/zcml_features.txt 2009-10-28 13:52:24 UTC (rev 105324)
@@ -0,0 +1,14 @@
+The zcml_layer can understand a "zcml_features" attribute, this attribute is set on the Layer that this test is in:
+
+ >>> from van.testing.tests import ZCMLExtraLayer
+ >>> ZCMLExtraLayer.zcml_features
+ ('extra',)
+
+Ths means our zcml was loaded with the "extra" extra and we can get the test_extra utility:
+
+ >>> from zope.interface import Interface
+ >>> from zope.component import queryUtility
+ >>> queryUtility(Interface, name="test", default='None')
+ 'MARKER'
+ >>> queryUtility(Interface, name="test_extra", default='None')
+ 'MARKER'
Property changes on: van.testing/trunk/van/testing/zcml_features.txt
___________________________________________________________________
Added: svn:eol-style
+ native
More information about the checkins
mailing list