Skip to content

Commit 0c9348e

Browse files
mnaberezalexsilva
authored andcommitted
Add more tests for inline comments in config
References Supervisor#1229 References Supervisor#1230 (cherry picked from commit a1643db)
1 parent 87631ce commit 0c9348e

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

supervisor/tests/test_options.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,27 @@ def test_options(self):
307307
self.assertEqual(options.password, '123')
308308
self.assertEqual(options.history_file, history_file)
309309

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

321332
def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
322333
text = lstrip("""
@@ -666,16 +677,30 @@ def test_options(self):
666677
self.assertEqual(instance.minfds, 2048)
667678
self.assertEqual(instance.minprocs, 300)
668679

669-
def test_options_ignores_inline_comments(self):
680+
def test_options_ignores_space_prefixed_inline_comments(self):
681+
text = lstrip("""
682+
[supervisord]
683+
logfile=/var/log/supervisor/supervisord.log ;(main log file;default $CWD/supervisord.log)
684+
minfds=123 ; (min. avail startup file descriptors;default 1024)
685+
""")
686+
instance = self._makeOne()
687+
instance.configfile = StringIO(text)
688+
instance.realize(args=[])
689+
options = instance.configroot.supervisord
690+
self.assertEqual(options.logfile, "/var/log/supervisor/supervisord.log")
691+
self.assertEqual(options.minfds, 123)
692+
693+
def test_options_ignores_tab_prefixed_inline_comments(self):
670694
text = lstrip("""
671695
[supervisord]
672-
identifier=foo ;comment should not be in identifier
696+
logfile=/var/log/supervisor/supervisord.log\t;(main log file;default $CWD/supervisord.log)
697+
minfds=123\t; (min. avail startup file descriptors;default 1024)
673698
""")
674699
instance = self._makeOne()
675700
instance.configfile = StringIO(text)
676701
instance.realize(args=[])
677702
options = instance.configroot.supervisord
678-
self.assertEqual(options.identifier, 'foo')
703+
self.assertEqual(options.minfds, 123)
679704

680705
def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
681706
text = lstrip("""

0 commit comments

Comments
 (0)