[Checkins] SVN: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/ * Provide a .app property on the layer to expose the current application.
Brian Sutherland
jinty at web.de
Fri Mar 4 04:02:24 EST 2011
Log message for revision 120745:
* Provide a .app property on the layer to expose the current application.
* Prevent people from accidentally setting up 2 layers. It makes no sense and
can only result in weird, difficult to find bugs.
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-04 08:33:51 UTC (rev 120744)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/tests/test_wsgi.py 2011-03-04 09:02:24 UTC (rev 120745)
@@ -41,3 +41,12 @@
browser.open('http://localhost')
self.assertTrue(browser.contents.startswith('Hello world!\n'))
# XXX test for authorization header munging is missing
+
+ 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)
+
+ def test_there_can_only_be_one(self):
+ another_layer = SimpleLayer()
+ # The layer has a .app property where the application under test is available
+ self.assertRaises(AssertionError, another_layer.setUp)
Modified: zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py
===================================================================
--- zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py 2011-03-04 08:33:51 UTC (rev 120744)
+++ zope.testbrowser/branches/jinty-webtest3/src/zope/testbrowser/wsgi.py 2011-03-04 09:02:24 UTC (rev 120745)
@@ -154,6 +154,10 @@
__bases__ = ()
__name__ = 'Layer'
+ @property
+ def app(self):
+ return _APP_UNDER_TEST
+
def make_wsgi_app(self):
# Override this method in subclasses of this layer in order to set up
# the WSGI application.
@@ -168,6 +172,8 @@
def setUp(self):
self.cooperative_super('setUp')
global _APP_UNDER_TEST
+ if _APP_UNDER_TEST is not None:
+ raise AssertionError("Already Setup")
_APP_UNDER_TEST = self.make_wsgi_app()
def tearDown(self):
More information about the checkins
mailing list