[Zope-Checkins]
SVN: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/
merging layers implementation
david whitfield Morriss
whit at longnow.org
Fri Aug 18 23:28:14 EDT 2006
Log message for revision 69681:
merging layers implementation
Changed:
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/sandbox.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
-=-
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -26,6 +26,7 @@
"""
import os, sys, time
+from utils import hasProduct, _print
# Allow code to tell it is run by the test framework
os.environ['ZOPETESTCASE'] = '1'
@@ -36,11 +37,6 @@
# Shut up if we are not in control of the import process
_quiet = sys.modules.has_key('Zope2')
-def _print(msg):
- '''Writes 'msg' to stderr and flushes the stream.'''
- sys.stderr.write(msg)
- sys.stderr.flush()
-
def _write(msg):
'''Writes 'msg' to stderr if not _quiet.'''
if not _quiet:
@@ -139,10 +135,6 @@
_theApp = Zope2.app()
_installedProducts = {}
-def hasProduct(name):
- '''Checks if a product can be found along Products.__path__'''
- return name in [n[1] for n in get_products()]
-
def installProduct(name, quiet=0):
'''Installs a Zope product.'''
start = time.time()
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -29,6 +29,7 @@
import interfaces
import utils
import connections
+import layer
from AccessControl import getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager
@@ -51,6 +52,8 @@
_setup_fixture = 1
+ layer = layer.Zope2Layer
+
def _setup(self):
'''Sets up the fixture. Framework authors may
override.
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -15,12 +15,12 @@
$Id$
"""
-import ZopeLite as Zope2
import utils
-from ZopeLite import hasProduct
-from ZopeLite import installProduct
-from ZopeLite import _print
+from utils import hasProduct
+from layer import installProduct
+from utils import _print
+from utils import setAllLayers
from ZopeTestCase import folder_name
from ZopeTestCase import user_name
@@ -49,9 +49,10 @@
from zopedoctest import FunctionalDocTestSuite
from zopedoctest import FunctionalDocFileSuite
+from layer import ZopeLiteLayer
+from layer import Zope2Layer
+
import zopedoctest as doctest
import transaction
import placeless
-Zope = Zope2
-
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -15,7 +15,6 @@
$Id$
"""
-import ZopeLite as Zope2
import unittest
import transaction
import profiler
@@ -25,10 +24,9 @@
from AccessControl.SecurityManagement import noSecurityManager
-
-
def app():
'''Opens a ZODB connection and returns the app object.'''
+ import ZopeLite as Zope2
app = Zope2.app()
app = utils.makerequest(app)
connections.register(app)
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -44,9 +44,6 @@
creation.
''' % orig_func.__doc__
- # Setup the placeless stuff that's needed to create a fixture
- setUp()
-
# Call any necessary callbacks for setting up ZCML
callZCML(required_zcml)
if kw.has_key('required_zcml'):
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/sandbox.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/sandbox.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/sandbox.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -14,14 +14,11 @@
$Id$
"""
-
-import ZopeLite as Zope2
import transaction
import base
import utils
import connections
-
class Sandboxed:
'''Derive from this class and an xTestCase to make each test
run in its own ZODB sandbox::
@@ -32,6 +29,7 @@
def _app(self):
'''Returns the app object for a test.'''
+ import ZopeLite as Zope2
app = Zope2.app(Zope2.sandbox().open())
AppZapper().set(app)
app = utils.makerequest(app)
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -18,4 +18,3 @@
from zope.testing.doctest import *
from zope.testing.doctest import _normalize_module
from functional import *
-
Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py 2006-08-19 03:11:51 UTC (rev 69680)
+++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py 2006-08-19 03:28:13 UTC (rev 69681)
@@ -298,23 +298,34 @@
| doctest.REPORT_NDIFF
| doctest.NORMALIZE_WHITESPACE)
+from Testing.ZopeTestCase.layer import Zope2Layer
+def setlayer(layer):
+ def wrapfactory(factory):
+ def wrapper(*args, **kwargs):
+ suite = factory(*args, **kwargs)
+ suite.layer=layer
+ return suite
+ return wrapper
+ return wrapfactory
+
+ at setlayer(Zope2Layer)
def ZopeDocTestSuite(module=None, **kw):
module = doctest._normalize_module(module)
return ZopeSuiteFactory(module, **kw).doctestsuite()
-
+ at setlayer(Zope2Layer)
def ZopeDocFileSuite(*paths, **kw):
if kw.get('module_relative', True):
kw['package'] = doctest._normalize_module(kw.get('package'))
return ZopeSuiteFactory(*paths, **kw).docfilesuite()
-
+ at setlayer(Zope2Layer)
def FunctionalDocTestSuite(module=None, **kw):
module = doctest._normalize_module(module)
return FunctionalSuiteFactory(module, **kw).doctestsuite()
-
+ at setlayer(Zope2Layer)
def FunctionalDocFileSuite(*paths, **kw):
if kw.get('module_relative', True):
kw['package'] = doctest._normalize_module(kw.get('package'))
More information about the Zope-Checkins
mailing list