Commit 41b687a5 authored by Chris McDonough's avatar Chris McDonough

Fix broken test that depended on Startup module having getSchema.

parent 3d5aa9a8
...@@ -30,14 +30,26 @@ from App.config import getConfiguration ...@@ -30,14 +30,26 @@ from App.config import getConfiguration
TEMPNAME = tempfile.mktemp() TEMPNAME = tempfile.mktemp()
TEMPPRODUCTS = os.path.join(TEMPNAME, "Products") TEMPPRODUCTS = os.path.join(TEMPNAME, "Products")
try:
__file__
except NameError:
import sys
__file__ = sys.argv[0]
def getSchema():
startup = os.path.dirname(os.path.dirname(__file__))
schemafile = os.path.join(startup, 'zopeschema.xml')
return ZConfig.loadSchema(schemafile)
class StartupTestCase(unittest.TestCase): class StartupTestCase(unittest.TestCase):
def setUp(self):
self.schema = getSchema()
def load_config_text(self, text): def load_config_text(self, text):
# We have to create a directory of our own since the existence # We have to create a directory of our own since the existence
# of the directory is checked. This handles this in a # of the directory is checked. This handles this in a
# platform-independent way. # platform-independent way.
schema = Zope.Startup.getSchema() schema = self.schema
sio = cStringIO.StringIO( sio = cStringIO.StringIO(
text.replace("<<INSTANCE_HOME>>", TEMPNAME)) text.replace("<<INSTANCE_HOME>>", TEMPNAME))
os.mkdir(TEMPNAME) os.mkdir(TEMPNAME)
...@@ -51,7 +63,7 @@ class StartupTestCase(unittest.TestCase): ...@@ -51,7 +63,7 @@ class StartupTestCase(unittest.TestCase):
return conf return conf
def test_load_config_template(self): def test_load_config_template(self):
schema = Zope.Startup.getSchema() schema = self.schema
cfg = getConfiguration() cfg = getConfiguration()
fn = os.path.join(cfg.zopehome, "skel", "etc", "zope.conf.in") fn = os.path.join(cfg.zopehome, "skel", "etc", "zope.conf.in")
f = open(fn) f = open(fn)
......
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