ソースを参照

Fix error message when program section has no command
This broke when d2481dde06bcb8b7d519f8d4092609f713c81a9f removed the
default value in the call to get().

Mike Naberezny 10 年 前
コミット
ab88e6b1c5
2 ファイル変更7 行追加4 行削除
  1. 1 1
      supervisor/options.py
  2. 6 3
      supervisor/tests/test_options.py

+ 1 - 1
supervisor/options.py

@@ -917,7 +917,7 @@ class ServerOptions(Options):
                         'rollover, set maxbytes > 0 to avoid filling up '
                         'filesystem unintentionally' % (section, n))
 
-            command = get(section, 'command', expansions=expansions)
+            command = get(section, 'command', None, expansions=expansions)
             if command is None:
                 raise ValueError(
                     'program section %s does not specify a command' % section)

+ 6 - 3
supervisor/tests/test_options.py

@@ -1113,13 +1113,16 @@ class ServerOptionsTests(unittest.TestCase):
         instance = self._makeOne()
         text = lstrip("""\
         [program:foo]
-        numprocs = 2
         """)
         from supervisor.options import UnhosedConfigParser
         config = UnhosedConfigParser()
         config.read_string(text)
-        self.assertRaises(ValueError, instance.processes_from_section,
-                          config, 'program:foo', None)
+        try:
+            instance.processes_from_section(config, 'program:foo', None)
+            self.fail('nothing raised')
+        except ValueError as exc:
+            self.assertTrue(exc.args[0].startswith(
+                'program section program:foo does not specify a command'))
 
     def test_processes_from_section_missing_replacement_in_process_name(self):
         instance = self._makeOne()