[Checkins] SVN: gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/ Extract sandbox patch and test helper methods
Wolfgang Schnerring
wosc at wosc.de
Sun Dec 26 08:40:52 EST 2010
Log message for revision 119126:
Extract sandbox patch and test helper methods
We're going to need them at least in the plone flavour, too
Changed:
U gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py
U gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py
-=-
Modified: gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py
===================================================================
--- gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py 2010-12-26 12:07:27 UTC (rev 119125)
+++ gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py 2010-12-26 13:40:52 UTC (rev 119126)
@@ -53,32 +53,28 @@
super(Layer, self).tearDown()
-class TestCase(gocept.selenium.base.TestCase,
- Testing.ZopeTestCase.FunctionalTestCase):
+class SandboxPatch(object):
+ # Testing.ZopeTestCase.sandbox.Sandbox swapping of the DemoStorage is a
+ # little... crude:
+ #
+ # ZApplicationWrapper is instantiated with a DB from
+ # Testing/custom_zodb, which is never used later on, since Sandbox
+ # passes in the connection (to the current DB) to use instead. This
+ # connection is also stored globally in
+ # Testing.ZopeTestCase.sandbox.AppZapper (and passed to requests via
+ # the bobo_traverse monkey-patch there) -- which means that there only
+ # ever is one single ZODB connection, among the test code and the HTTP
+ # requests, and among concurrent requests. This clearly is not what we
+ # want.
+ #
+ # Thus, this rewrite of the upstream method, that properly changes the
+ # DB in ZApplicationWrapper and does *not* use AppZapper, yielding a
+ # new connection upon each traversal. (For reference and since it took
+ # me quite a while to figure out where everything is: this code is
+ # adapted from the original Sandbox._app and the normal Zope2 startup
+ # in Zope2.__init__).
- layer = Layer(*BASE_LAYERS)
-
def _app(self):
- # Testing.ZopeTestCase.sandbox.Sandbox swapping of the DemoStorage is a
- # little... crude:
- #
- # ZApplicationWrapper is instantiated with a DB from
- # Testing/custom_zodb, which is never used later on, since Sandbox
- # passes in the connection (to the current DB) to use instead. This
- # connection is also stored globally in
- # Testing.ZopeTestCase.sandbox.AppZapper (and passed to requests via
- # the bobo_traverse monkey-patch there) -- which means that there only
- # ever is one single ZODB connection, among the test code and the HTTP
- # requests, and among concurrent requests. This clearly is not what we
- # want.
- #
- # Thus, this rewrite of the upstream method, that properly changes the
- # DB in ZApplicationWrapper and does *not* use AppZapper, yielding a
- # new connection upon each traversal. (For reference and since it took
- # me quite a while to figure out where everything is: this code is
- # adapted from the original Sandbox._app and the normal Zope2 startup
- # in Zope2.__init__).
-
Zope2.startup()
db, aname, version = Zope2.bobo_application._stuff
db = Testing.ZopeTestCase.ZopeLite.sandbox()
@@ -87,3 +83,20 @@
app = Testing.ZopeTestCase.utils.makerequest(app)
Testing.ZopeTestCase.connections.register(app)
return app
+
+
+def get_current_db():
+ """helper for gocept.selenium.tests.isolation"""
+ db, aname, version = Zope2.bobo_application._stuff
+ return db
+
+
+class TestCase(gocept.selenium.base.TestCase,
+ SandboxPatch,
+ Testing.ZopeTestCase.FunctionalTestCase):
+
+ layer = Layer(*BASE_LAYERS)
+
+ def getRootFolder(self):
+ """forward API-compatibility with zope.app.testing"""
+ return self.app
Modified: gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py
===================================================================
--- gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py 2010-12-26 12:07:27 UTC (rev 119125)
+++ gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py 2010-12-26 13:40:52 UTC (rev 119126)
@@ -13,7 +13,6 @@
##############################################################################
import Testing.ZopeTestCase
-import Zope2
import gocept.selenium.tests.isolation
import gocept.selenium.zope2
import unittest
@@ -24,12 +23,8 @@
class Zope2Tests(gocept.selenium.tests.isolation.IsolationTests,
gocept.selenium.zope2.TestCase):
- def getRootFolder(self):
- return self.app
-
def getDatabase(self):
- db, aname, version = Zope2.bobo_application._stuff
- return db
+ return gocept.selenium.zope2.get_current_db()
def test_suite():
More information about the checkins
mailing list