Skip to content

Commit

Permalink
Add more tests for inline comments in config
Browse files Browse the repository at this point in the history
References Supervisor#1229
References Supervisor#1230

(cherry picked from commit a1643db)
  • Loading branch information
mnaberez authored and alexsilva committed Aug 22, 2019
1 parent 87631ce commit 0c9348e
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions supervisor/tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,27 @@ def test_options(self):
self.assertEqual(options.password, '123')
self.assertEqual(options.history_file, history_file)

def test_options_ignores_inline_comments(self):
def test_options_ignores_space_prefixed_inline_comments(self):
text = lstrip("""
[supervisorctl]
serverurl=http://localhost:9001 ;comment should not be in serverurl
serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
""")
instance = self._makeOne()
instance.configfile = StringIO(text)
instance.realize(args=[])
options = instance.configroot.supervisorctl
self.assertEqual(options.serverurl, 'http://localhost:9001')
self.assertEqual(options.serverurl, 'http://127.0.0.1:9001')

def test_options_ignores_tab_prefixed_inline_comments(self):
text = lstrip("""
[supervisorctl]
serverurl=http://127.0.0.1:9001\t;use an http:// url to specify an inet socket
""")
instance = self._makeOne()
instance.configfile = StringIO(text)
instance.realize(args=[])
options = instance.configroot.supervisorctl
self.assertEqual(options.serverurl, 'http://127.0.0.1:9001')

def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
text = lstrip("""
Expand Down Expand Up @@ -666,16 +677,30 @@ def test_options(self):
self.assertEqual(instance.minfds, 2048)
self.assertEqual(instance.minprocs, 300)

def test_options_ignores_inline_comments(self):
def test_options_ignores_space_prefixed_inline_comments(self):
text = lstrip("""
[supervisord]
logfile=/var/log/supervisor/supervisord.log ;(main log file;default $CWD/supervisord.log)
minfds=123 ; (min. avail startup file descriptors;default 1024)
""")
instance = self._makeOne()
instance.configfile = StringIO(text)
instance.realize(args=[])
options = instance.configroot.supervisord
self.assertEqual(options.logfile, "/var/log/supervisor/supervisord.log")
self.assertEqual(options.minfds, 123)

def test_options_ignores_tab_prefixed_inline_comments(self):
text = lstrip("""
[supervisord]
identifier=foo ;comment should not be in identifier
logfile=/var/log/supervisor/supervisord.log\t;(main log file;default $CWD/supervisord.log)
minfds=123\t; (min. avail startup file descriptors;default 1024)
""")
instance = self._makeOne()
instance.configfile = StringIO(text)
instance.realize(args=[])
options = instance.configroot.supervisord
self.assertEqual(options.identifier, 'foo')
self.assertEqual(options.minfds, 123)

def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
text = lstrip("""
Expand Down

0 comments on commit 0c9348e

Please sign in to comment.