[Checkins] SVN: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py Introduce 'sane' layer base, similar to the one in zope.component.testlayer. This layer will be used in the static/wsgi and grok selenium layers.

Jan-Jaap Driessen jdriessen at thehealthagency.com
Wed Dec 1 08:39:38 EST 2010


Log message for revision 118656:
  Introduce 'sane' layer base, similar to the one in zope.component.testlayer. This layer will be used in the static/wsgi and grok selenium layers.

Changed:
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py

-=-
Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py	2010-12-01 12:56:42 UTC (rev 118655)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/base.py	2010-12-01 13:39:37 UTC (rev 118656)
@@ -18,7 +18,7 @@
 import gocept.selenium.selenese
 
 
-class Layer(object):
+class LayerBase(object):
 
     # hostname and port of the Selenium RC server
     _server = os.environ.get('GOCEPT_SELENIUM_SERVER_HOST', 'localhost')
@@ -49,10 +49,40 @@
     def tearDown(self):
         self.selenium.stop()
 
+
+class Layer(LayerBase):
+    __name__ = 'Layer'
+
+    def __init__(self, *bases):
+        self.__bases__ = bases
+        self.__name__ = '[%s].selenium' % (
+            '/'.join('%s.%s' % (x.__module__, x.__name__) for x in bases))
+
     def testSetUp(self):
         pass
 
+    def testTearDown(self):
+        pass
 
+
+class SaneLayer(LayerBase):
+    """Sane layer base class.
+
+    Sane test layer base class inspired by zope.component.testlayer.
+
+    The hack requires us to set __bases__, __module__ and __name__.
+    This fools zope.testrunner into thinking that this layer instance is
+    an object it can work with.
+    """
+
+    __bases__ = ()
+
+    def __init__(self, name=None):
+        if name is None:
+            name = self.__class__.__name__
+        self.__name__ = name
+
+
 class TestCase(object):
 
     def setUp(self):



More information about the checkins mailing list