[Zope-Checkins] CVS: ZODB3/zdaemon/tests - testzdrun.py:1.7.2.1 testzdoptions.py:1.11.32.1

Jeremy Hylton jeremy at zope.com
Tue Dec 23 14:06:47 EST 2003


Update of /cvs-repository/ZODB3/zdaemon/tests
In directory cvs.zope.org:/tmp/cvs-serv26665/zdaemon/tests

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	testzdrun.py testzdoptions.py 
Log Message:
Merge the head to the mvcc branch.

This merge should be the final preparation for merging the branch to
the trunk.


=== ZODB3/zdaemon/tests/testzdrun.py 1.7 => 1.7.2.1 ===
--- ZODB3/zdaemon/tests/testzdrun.py:1.7	Thu Oct  2 18:14:05 2003
+++ ZODB3/zdaemon/tests/testzdrun.py	Tue Dec 23 14:05:46 2003
@@ -7,9 +7,38 @@
 import tempfile
 import unittest
 import socket
+
 from StringIO import StringIO
+
+import ZConfig
+
 from zdaemon import zdrun, zdctl
 
+
+class ConfiguredOptions:
+    """Options class that loads configuration from a specified string.
+
+    This always loads from the string, regardless of any -C option
+    that may be given.
+    """
+
+    def set_configuration(self, configuration):
+        self.__configuration = configuration
+        self.configfile = "<preloaded string>"
+
+    def load_configfile(self):
+        sio = StringIO(self.__configuration)
+        cfg = ZConfig.loadConfigFile(self.schema, sio, self.zconfig_options)
+        self.configroot, self.confighandlers = cfg
+
+
+class ConfiguredZDRunOptions(ConfiguredOptions, zdrun.ZDRunOptions):
+
+    def __init__(self, configuration):
+        zdrun.ZDRunOptions.__init__(self)
+        self.set_configuration(configuration)
+
+
 class ZDaemonTests(unittest.TestCase):
 
     python = os.path.abspath(sys.executable)
@@ -145,6 +174,37 @@
         self.assertEqual(os.WTERMSIG(wsts), signal.SIGTERM)
         proc.setstatus(wsts)
         self.assertEqual(proc.pid, 0)
+
+    def testEventlogOverride(self):
+        # Make sure runner.eventlog is used if it exists
+        options = ConfiguredZDRunOptions("""\
+            <runner>
+              program /bin/true
+              <eventlog>
+                level 42
+              </eventlog>
+            </runner>
+
+            <eventlog>
+              level 35
+            </eventlog>
+            """)
+        options.realize(["/bin/true"])
+        self.assertEqual(options.config_logger.level, 42)
+
+    def testEventlogWithoutOverride(self):
+        # Make sure eventlog is used if runner.eventlog doesn't exist
+        options = ConfiguredZDRunOptions("""\
+            <runner>
+              program /bin/true
+            </runner>
+
+            <eventlog>
+              level 35
+            </eventlog>
+            """)
+        options.realize(["/bin/true"])
+        self.assertEqual(options.config_logger.level, 35)
 
     def testRunIgnoresParentSignals(self):
         # Spawn a process which will in turn spawn a zdrun process.


=== ZODB3/zdaemon/tests/testzdoptions.py 1.11 => 1.11.32.1 ===
--- ZODB3/zdaemon/tests/testzdoptions.py:1.11	Thu Feb 20 10:37:41 2003
+++ ZODB3/zdaemon/tests/testzdoptions.py	Tue Dec 23 14:05:46 2003
@@ -152,6 +152,14 @@
         options.add("setting", None, "a:", handler=int)
         self.check_exit_code(options, ["-afoo"])
 
+    def test_raise_getopt_errors(self):
+        options = self.OptionsClass()
+        # note that we do not add "a" to the list of options;
+        # if raise_getopt_errors was true, this test would error
+        options.realize(["-afoo"], raise_getopt_errs=False)
+        # check_exit_code realizes the options with raise_getopt_errs=True
+        self.check_exit_code(options, ['-afoo'])
+                                       
 
 class EnvironmentOptions(ZDOptionsTestBase):
 




More information about the Zope-Checkins mailing list