[Checkins] SVN: zc.selenium/branches/wosc-zope2/ register tests as views in a zope2-compatible way
Wolfgang Schnerring
wosc at wosc.de
Tue Feb 17 05:52:39 EST 2009
Log message for revision 96638:
register tests as views in a zope2-compatible way
Changed:
U zc.selenium/branches/wosc-zope2/buildout.cfg
U zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py
U zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt
U zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml
-=-
Modified: zc.selenium/branches/wosc-zope2/buildout.cfg
===================================================================
--- zc.selenium/branches/wosc-zope2/buildout.cfg 2009-02-17 10:48:27 UTC (rev 96637)
+++ zc.selenium/branches/wosc-zope2/buildout.cfg 2009-02-17 10:52:38 UTC (rev 96638)
@@ -1,3 +1,3 @@
[buildout]
-#extends = zope3.cfg
-extends = zope2.cfg
+extends = zope3.cfg
+#extends = zope2.cfg
Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py 2009-02-17 10:48:27 UTC (rev 96637)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.py 2009-02-17 10:52:38 UTC (rev 96638)
@@ -185,8 +185,15 @@
def __str__(self):
return ''.join(self.output) + footer
+# zope2 compatibility
+try:
+ from Products.Five import BrowserView as TestBase
+except ImportError:
+ TestBase = object
-class Test(object):
+class Test(TestBase):
+ component.adapts(interface.Interface,
+ zope.publisher.interfaces.browser.IDefaultBrowserLayer)
interface.implements(ISeleniumTest)
def __init__(self, context, request):
@@ -199,7 +206,10 @@
mess += '<br/>\n'.join((self.__doc__ or '').split('\n')[1:])
self.selenium = Selenium(self.request, title, mess)
+ # XXX zope2 compatibility. I have no idea why we don't get a __name__
+ self.__name__ = 'zc.selenium.' + type(self).__name__
+ # we can't use browser:page to register this for us
def browserDefault(self, request):
return self, ()
Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt 2009-02-17 10:48:27 UTC (rev 96637)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/pytest.txt 2009-02-17 10:52:38 UTC (rev 96638)
@@ -493,16 +493,20 @@
Registration
------------
-To get our tests to be used in the Selenium test suite, we need to
-register them as views for "*". We would normally use ZCML like
-the following::
+To get our tests to be used in the Selenium test suite, we need to register them
+as adapters for "*". We would normally use ZCML like the following::
- <browser:page
- for="*"
+ <adapter
name="some-url-for-the-second-test.html"
- class=".Second"
+ factory=".Second"
permission="zope.Public"
/>
+(This differs from using browser:view in one important aspect: browser:view
+registers the adapter to provide Interface, but this registration registers
+it to provide ISeleniumTest. With this registration, it will be found both as
+a view and a selenium test case. When using Zope2, you also need to add
+provides="zc.selenium.pytest.ISeleniumTest" since for compatibility reasons
+the Test base class there needs to inherit a lot of stuff.)
We'll illustrate this using the component API:
Modified: zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml
===================================================================
--- zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml 2009-02-17 10:48:27 UTC (rev 96637)
+++ zc.selenium/branches/wosc-zope2/src/zc/selenium/tests.zcml 2009-02-17 10:52:38 UTC (rev 96638)
@@ -1,10 +1,11 @@
<configure
- xmlns="http://namespaces.zope.org/browser">
+ xmlns="http://namespaces.zope.org/zope">
- <page
- for="*"
+ <!-- provides is only necessary for zope2 -->
+ <adapter
name="zc.selenium.tests.TestSelenium"
- class=".tests.TestSelenium"
+ factory=".tests.TestSelenium"
+ provides="zc.selenium.pytest.ISeleniumTest"
permission="zope.Public"
/>
More information about the Checkins
mailing list