[Checkins] SVN: gocept.selenium/trunk/src/gocept/selenium/ avoid the need for a specific TestCase class by moving Selenese instance to

Godefroid Chapelle gotcha at bubblenet.be
Tue Dec 21 08:43:23 EST 2010


Log message for revision 119029:
  avoid the need for a specific TestCase class by moving Selenese instance to
  layer
  

Changed:
  U   gocept.selenium/trunk/src/gocept/selenium/plone/tests/plonetesting4/test_plone4.py
  U   gocept.selenium/trunk/src/gocept/selenium/zope2/plonetesting.py
  U   gocept.selenium/trunk/src/gocept/selenium/zope2/tests/plonetesting/test_zope212.py

-=-
Modified: gocept.selenium/trunk/src/gocept/selenium/plone/tests/plonetesting4/test_plone4.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/plone/tests/plonetesting4/test_plone4.py	2010-12-21 13:30:29 UTC (rev 119028)
+++ gocept.selenium/trunk/src/gocept/selenium/plone/tests/plonetesting4/test_plone4.py	2010-12-21 13:43:22 UTC (rev 119029)
@@ -35,13 +35,19 @@
     name="gocept.selenium:Plone4")
 
 
-class Plone4Tests(gocept.selenium.tests.isolation.IsolationTests,
-                 plonetesting.TestCase):
+class Plone4Tests(unittest.TestCase,
+    gocept.selenium.tests.isolation.IsolationTests):
 
     layer = PLONE_SELENIUM
 
+    @property
+    def selenium(self):
+        # property needed to reuse IsolationTests without touching them
+        # should not be needed in usual tests; see hereunder
+        return self.layer['selenese']
+
     def test_plone_login(self):
-        sel = self.selenium
+        sel = self.layer['selenese']
         sel.open('/plone')
         sel.click('link=Log in')
         sel.waitForElementPresent('name=__ac_name')

Modified: gocept.selenium/trunk/src/gocept/selenium/zope2/plonetesting.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/zope2/plonetesting.py	2010-12-21 13:30:29 UTC (rev 119028)
+++ gocept.selenium/trunk/src/gocept/selenium/zope2/plonetesting.py	2010-12-21 13:43:22 UTC (rev 119029)
@@ -1,5 +1,4 @@
 import selenium
-import unittest
 
 from plone.testing import Layer
 from plone.testing.z2 import ZSERVER_FIXTURE
@@ -21,17 +20,11 @@
             self._rc_server, self._rc_port, self._browser,
             'http://%s:%s/' % (self['host'], self['port']))
         self.selenium.start()
+        self['selenese'] = gocept.selenium.selenese.Selenese(
+            self.selenium, self['host'], self['port'])
 
     def tearDown(self):
         super(Selenium, self).tearDown()
         self.selenium.stop()
 
 SELENIUM = Selenium()
-
-
-class TestCase(unittest.TestCase):
-
-    def setUp(self):
-        super(TestCase, self).setUp()
-        self.selenium = gocept.selenium.selenese.Selenese(
-            self.layer['selenium'], self.layer['host'], self.layer['port'])

Modified: gocept.selenium/trunk/src/gocept/selenium/zope2/tests/plonetesting/test_zope212.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/zope2/tests/plonetesting/test_zope212.py	2010-12-21 13:30:29 UTC (rev 119028)
+++ gocept.selenium/trunk/src/gocept/selenium/zope2/tests/plonetesting/test_zope212.py	2010-12-21 13:43:22 UTC (rev 119029)
@@ -24,11 +24,17 @@
     name="gocept.selenium:Zope2.12")
 
 
-class Zope212Tests(gocept.selenium.tests.isolation.IsolationTests,
-                 plonetesting.TestCase):
+class Zope212Tests(unittest.TestCase,
+    gocept.selenium.tests.isolation.IsolationTests):
 
     layer = ZOPE2_ISOLATION
 
+    @property
+    def selenium(self):
+        # property needed to reuse IsolationTests without touching them
+        # should not be needed in usual tests; see plone4 tests for example
+        return self.layer['selenese']
 
+
 def test_suite():
     return unittest.makeSuite(Zope212Tests)



More information about the checkins mailing list