Skip to content

Commit a1643db

Browse files
committed
Add more tests for inline comments in config
References #1229 References #1230
1 parent 92a3d2a commit a1643db

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

supervisor/tests/test_options.py

+31-6
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,27 @@ def test_options(self):
305305
self.assertEqual(options.password, '123')
306306
self.assertEqual(options.history_file, history_file)
307307

308-
def test_options_ignores_inline_comments(self):
308+
def test_options_ignores_space_prefixed_inline_comments(self):
309309
text = lstrip("""
310310
[supervisorctl]
311-
serverurl=http://localhost:9001 ;comment should not be in serverurl
311+
serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
312312
""")
313313
instance = self._makeOne()
314314
instance.configfile = StringIO(text)
315315
instance.realize(args=[])
316316
options = instance.configroot.supervisorctl
317-
self.assertEqual(options.serverurl, 'http://localhost:9001')
317+
self.assertEqual(options.serverurl, 'http://127.0.0.1:9001')
318+
319+
def test_options_ignores_tab_prefixed_inline_comments(self):
320+
text = lstrip("""
321+
[supervisorctl]
322+
serverurl=http://127.0.0.1:9001\t;use an http:// url to specify an inet socket
323+
""")
324+
instance = self._makeOne()
325+
instance.configfile = StringIO(text)
326+
instance.realize(args=[])
327+
options = instance.configroot.supervisorctl
328+
self.assertEqual(options.serverurl, 'http://127.0.0.1:9001')
318329

319330
def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
320331
text = lstrip("""
@@ -692,16 +703,30 @@ def test_options(self):
692703
self.assertEqual(instance.minfds, 2048)
693704
self.assertEqual(instance.minprocs, 300)
694705

695-
def test_options_ignores_inline_comments(self):
706+
def test_options_ignores_space_prefixed_inline_comments(self):
707+
text = lstrip("""
708+
[supervisord]
709+
logfile=/var/log/supervisor/supervisord.log ;(main log file;default $CWD/supervisord.log)
710+
minfds=123 ; (min. avail startup file descriptors;default 1024)
711+
""")
712+
instance = self._makeOne()
713+
instance.configfile = StringIO(text)
714+
instance.realize(args=[])
715+
options = instance.configroot.supervisord
716+
self.assertEqual(options.logfile, "/var/log/supervisor/supervisord.log")
717+
self.assertEqual(options.minfds, 123)
718+
719+
def test_options_ignores_tab_prefixed_inline_comments(self):
696720
text = lstrip("""
697721
[supervisord]
698-
identifier=foo ;comment should not be in identifier
722+
logfile=/var/log/supervisor/supervisord.log\t;(main log file;default $CWD/supervisord.log)
723+
minfds=123\t; (min. avail startup file descriptors;default 1024)
699724
""")
700725
instance = self._makeOne()
701726
instance.configfile = StringIO(text)
702727
instance.realize(args=[])
703728
options = instance.configroot.supervisord
704-
self.assertEqual(options.identifier, 'foo')
729+
self.assertEqual(options.minfds, 123)
705730

706731
def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
707732
text = lstrip("""

0 commit comments

Comments
 (0)