Преглед изворни кода

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 година
родитељ
комит
4ee29b35e8
2 измењених фајлова са 7 додато и 4 уклоњено
  1. 1 1
      supervisor/options.py
  2. 6 3
      supervisor/tests/test_options.py

+ 1 - 1
supervisor/options.py

@@ -950,7 +950,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

@@ -1269,13 +1269,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()