[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup/tests - test_schema.py:1.7

Chris McDonough chrism@zope.com
Mon, 21 Jul 2003 16:56:33 -0400


Update of /cvs-repository/Zope/lib/python/Zope/Startup/tests
In directory cvs.zope.org:/tmp/cvs-serv27325/tests

Modified Files:
	test_schema.py 
Log Message:
Fix broken test that depended on Startup module having getSchema.


=== Zope/lib/python/Zope/Startup/tests/test_schema.py 1.6 => 1.7 ===
--- Zope/lib/python/Zope/Startup/tests/test_schema.py:1.6	Tue Jul  8 01:25:19 2003
+++ Zope/lib/python/Zope/Startup/tests/test_schema.py	Mon Jul 21 16:56:27 2003
@@ -30,14 +30,26 @@
 TEMPNAME = tempfile.mktemp()
 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):
+    def setUp(self):
+        self.schema = getSchema()
 
     def load_config_text(self, text):
         # We have to create a directory of our own since the existence
         # of the directory is checked.  This handles this in a
         # platform-independent way.
-        schema = Zope.Startup.getSchema()
+        schema = self.schema
         sio = cStringIO.StringIO(
             text.replace("<<INSTANCE_HOME>>", TEMPNAME))
         os.mkdir(TEMPNAME)
@@ -51,7 +63,7 @@
         return conf
 
     def test_load_config_template(self):
-        schema = Zope.Startup.getSchema()
+        schema = self.schema
         cfg = getConfiguration()
         fn = os.path.join(cfg.zopehome, "skel", "etc", "zope.conf.in")
         f = open(fn)