Browse Source

Add test for process_num expansion in command

Mike Naberezny 10 years ago
parent
commit
3ae192f558
1 changed files with 16 additions and 0 deletions
  1. 16 0
      supervisor/tests/test_options.py

+ 16 - 0
supervisor/tests/test_options.py

@@ -1066,6 +1066,22 @@ class ServerOptionsTests(unittest.TestCase):
         expected = "/bin/foo --host=" + platform.node()
         self.assertEqual(pconfigs[0].command, expected)
 
+    def test_processes_from_section_process_num_expansion(self):
+        instance = self._makeOne()
+        text = lstrip("""\
+        [program:foo]
+        command = /bin/foo --num=%(process_num)d
+        process_name = foo_%(process_num)d
+        numprocs = 2
+        """)
+        from supervisor.options import UnhosedConfigParser
+        config = UnhosedConfigParser()
+        config.read_string(text)
+        pconfigs = instance.processes_from_section(config, 'program:foo', 'bar')
+        self.assertEqual(len(pconfigs), 2)
+        self.assertEqual(pconfigs[0].command, "/bin/foo --num=0")
+        self.assertEqual(pconfigs[1].command, "/bin/foo --num=1")
+
     def test_processes_from_section_environment_variables_expansion(self):
         instance = self._makeOne()
         text = lstrip("""\