[Checkins] SVN: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ Expose the application as a classmethod rather than a property. That way we don't need an instantiated layer to get the application

Brian Sutherland jinty at web.de
Mon Mar 7 06:16:57 EST 2011


Log message for revision 120786:
  Expose the application as a classmethod rather than a property. That way we don't need an instantiated layer to get the application

Changed:
  U   zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/tests/test_wsgi.py
  U   zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py

-=-
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/tests/test_wsgi.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/tests/test_wsgi.py	2011-03-07 11:07:46 UTC (rev 120785)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/tests/test_wsgi.py	2011-03-07 11:16:56 UTC (rev 120786)
@@ -69,7 +69,7 @@
 
     def test_app_property(self):
         # The layer has a .app property where the application under test is available
-        self.assertTrue(SIMPLE_LAYER.app is demo_app)
+        self.assertTrue(SIMPLE_LAYER.get_app() is demo_app)
 
     def test_there_can_only_be_one(self):
         another_layer = SimpleLayer()

Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py	2011-03-07 11:07:46 UTC (rev 120785)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py	2011-03-07 11:16:56 UTC (rev 120786)
@@ -161,14 +161,12 @@
 
     def __init__(self, url=None, wsgi_app=None):
         if wsgi_app is None:
-            wsgi_app = _APP_UNDER_TEST
+            wsgi_app = Layer.get_app()
         if wsgi_app is None:
             raise AssertionError("wsgi_app not provided or zope.testbrowser.wsgi.Layer not setup")
         mech_browser = WSGIMechanizeBrowser(wsgi_app)
         super(Browser, self).__init__(url=url, mech_browser=mech_browser)
 
-_APP_UNDER_TEST = None # setup and torn down by the Layer class
-
 # Compatibility helpers to behave like zope.app.testing
 
 basicre = re.compile('Basic (.+)?:(.+)?$')
@@ -222,6 +220,9 @@
         for entry in self.wsgi_stack(environ, application_start_response):
             yield entry
 
+
+_APP_UNDER_TEST = None # setup and torn down by the Layer class
+
 class Layer(object):
     """Test layer which sets up WSGI application for use with
     WebTest/testbrowser.
@@ -231,8 +232,8 @@
     __bases__ = ()
     __name__ = 'Layer'
 
-    @property
-    def app(self):
+    @classmethod
+    def get_app(cls):
         return _APP_UNDER_TEST
 
     def make_wsgi_app(self):



More information about the checkins mailing list