Commit 275b3389 authored by matt@zope.com's avatar matt@zope.com

Remove "import Zope" and replace with some slightly less evil stuff

parent c8a8c175
...@@ -16,19 +16,49 @@ from Products.PythonScripts.PythonScript import PythonScript ...@@ -16,19 +16,49 @@ from Products.PythonScripts.PythonScript import PythonScript
from ZODB.POSException import InvalidObjectReference from ZODB.POSException import InvalidObjectReference
from DateTime import DateTime from DateTime import DateTime
from unittest import TestCase, TestSuite, TextTestRunner, makeSuite from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
from ZODB.DemoStorage import DemoStorage
from OFS.Application import Application
import time, threading, whrandom import time, threading, whrandom
epoch = time.time() epoch = time.time()
stuff = {}
def _getApp():
app = stuff.get('app', None)
if not app:
ds = DemoStorage(quota=(1<<20))
db = ZODB.DB(ds)
conn = db.open()
root = conn.root()
app = Application()
root['Application']= app
get_transaction().commit()
stuff['app'] = app
stuff['conn'] = conn
stuff['db'] = db
return app
def _openApp():
conn = stuff['db'].open()
root = conn.root()
app = root['Application']
return conn, app
def _delApp():
get_transaction().abort()
stuff['conn'].close()
del stuff['conn']
del stuff['app']
del stuff['db']
class TestBase(TestCase): class TestBase(TestCase):
def setUp(self): def setUp(self):
import Zope
Products.Transience.Transience.time = fauxtime Products.Transience.Transience.time = fauxtime
self.app = makerequest.makerequest(Zope.app()) self.app = makerequest.makerequest(_getApp())
del Zope
timeout = self.timeout = 1 timeout = self.timeout = 1
...@@ -41,8 +71,9 @@ class TestBase(TestCase): ...@@ -41,8 +71,9 @@ class TestBase(TestCase):
def tearDown(self): def tearDown(self):
get_transaction().abort() get_transaction().abort()
self.app._p_jar.close() #self.app._p_jar.close()
self.app = None #self.app = None
_delApp()
del self.app del self.app
class TestLastAccessed(TestBase): class TestLastAccessed(TestBase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment