Преглед на файлове

Add tests for reading config files with inline comments

Mike Naberezny преди 10 години
родител
ревизия
8b388cf230
променени са 1 файла, в които са добавени 22 реда и са изтрити 0 реда
  1. 22 0
      supervisor/tests/test_options.py

+ 22 - 0
supervisor/tests/test_options.py

@@ -300,6 +300,17 @@ class ClientOptionsTests(unittest.TestCase):
         self.assertEqual(options.password, '123')
         self.assertEqual(options.history_file, history_file)
 
+    def test_options_ignores_inline_comments(self):
+        text = lstrip("""
+        [supervisorctl]
+        serverurl=http://localhost:9001 ;comment should not be in serverurl
+        """)
+        instance = self._makeOne()
+        instance.configfile = StringIO(text)
+        instance.realize(args=[])
+        options = instance.configroot.supervisorctl
+        self.assertEqual(options.serverurl, 'http://localhost:9001')
+
     def test_options_with_environment_expansions(self):
         s = lstrip("""[supervisorctl]
         serverurl=http://localhost:%(ENV_SERVER_PORT)s
@@ -641,6 +652,17 @@ class ServerOptionsTests(unittest.TestCase):
         self.assertEqual(instance.minfds, 2048)
         self.assertEqual(instance.minprocs, 300)
 
+    def test_options_ignores_inline_comments(self):
+        text = lstrip("""
+        [supervisord]
+        identifier=foo ;comment should not be in identifier
+        """)
+        instance = self._makeOne()
+        instance.configfile = StringIO(text)
+        instance.realize(args=[])
+        options = instance.configroot.supervisord
+        self.assertEqual(options.identifier, 'foo')
+
     def test_reload(self):
         text = lstrip("""\
         [supervisord]