@@ -341,7 +341,8 @@ def test_options_parses_as_nonstrict_for_py2_py3_compat(self):
341341 # should not raise configparser.DuplicateSectionError on py3
342342
343343 def test_options_with_environment_expansions (self ):
344- s = lstrip ("""[supervisorctl]
344+ s = lstrip ("""
345+ [supervisorctl]
345346 serverurl=http://localhost:%(ENV_SERVER_PORT)s
346347 username=%(ENV_CLIENT_USER)s
347348 password=%(ENV_CLIENT_PASS)s
@@ -454,11 +455,7 @@ def test_version(self):
454455 self .assertEqual (options .stdout .getvalue (), VERSION + '\n ' )
455456
456457 def test_options (self ):
457- s = lstrip ("""[inet_http_server]
458- port=127.0.0.1:8999
459- username=chrism
460- password=foo
461-
458+ s = lstrip ("""
462459 [supervisord]
463460 directory=%(tempdir)s
464461 backofflimit=10
@@ -478,6 +475,11 @@ def test_options(self):
478475 minprocs=300
479476 environment=FAKE_ENV_VAR=/some/path
480477
478+ [inet_http_server]
479+ port=127.0.0.1:8999
480+ username=chrism
481+ password=foo
482+
481483 [program:cat1]
482484 command=/bin/cat
483485 priority=1
@@ -1844,11 +1846,6 @@ def test_processes_from_section_redirect_stderr_with_auto(self):
18441846
18451847 def test_options_with_environment_expansions (self ):
18461848 text = lstrip ("""\
1847- [inet_http_server]
1848- port=*:%(ENV_HTSRV_PORT)s
1849- username=%(ENV_HTSRV_USER)s
1850- password=%(ENV_HTSRV_PASS)s
1851-
18521849 [supervisord]
18531850 logfile = %(ENV_HOME)s/supervisord.log
18541851 logfile_maxbytes = %(ENV_SUPD_LOGFILE_MAXBYTES)s
@@ -1864,6 +1861,11 @@ def test_options_with_environment_expansions(self):
18641861 strip_ansi = %(ENV_SUPD_STRIP_ANSI)s
18651862 environment = FAKE_ENV_VAR=/some/path
18661863
1864+ [inet_http_server]
1865+ port=*:%(ENV_HTSRV_PORT)s
1866+ username=%(ENV_HTSRV_USER)s
1867+ password=%(ENV_HTSRV_PASS)s
1868+
18671869 [program:cat1]
18681870 command=%(ENV_CAT1_COMMAND)s --logdir=%(ENV_CAT1_COMMAND_LOGDIR)s
18691871 priority=%(ENV_CAT1_PRIORITY)s
@@ -1996,6 +1998,57 @@ def test_options_supervisord_section_expands_here(self):
19961998 self .assertEqual (instance .pidfile ,
19971999 os .path .join (here , 'supervisord.pid' ))
19982000
2001+ def test_options_program_section_expands_env_from_supervisord_sect (self ):
2002+ instance = self ._makeOne ()
2003+ text = lstrip ('''
2004+ [supervisord]
2005+ environment=CMD=/bin/from/supervisord/section
2006+
2007+ [program:cmd]
2008+ command=%(ENV_CMD)s
2009+ ''' )
2010+ here = tempfile .mkdtemp ()
2011+ supervisord_conf = os .path .join (here , 'supervisord.conf' )
2012+ with open (supervisord_conf , 'w' ) as f :
2013+ f .write (text )
2014+ try :
2015+ instance .configfile = supervisord_conf
2016+ instance .realize (args = [])
2017+ finally :
2018+ shutil .rmtree (here , ignore_errors = True )
2019+ options = instance .configroot .supervisord
2020+ group = options .process_group_configs [0 ]
2021+ self .assertEqual (group .name , 'cmd' )
2022+ proc = group .process_configs [0 ]
2023+ self .assertEqual (proc .command ,
2024+ os .path .join (here , '/bin/from/supervisord/section' ))
2025+
2026+ def test_options_program_section_expands_env_from_program_sect (self ):
2027+ instance = self ._makeOne ()
2028+ text = lstrip ('''
2029+ [supervisord]
2030+ environment=CMD=/bin/from/supervisord/section
2031+
2032+ [program:cmd]
2033+ command=%(ENV_CMD)s
2034+ environment=CMD=/bin/from/program/section
2035+ ''' )
2036+ here = tempfile .mkdtemp ()
2037+ supervisord_conf = os .path .join (here , 'supervisord.conf' )
2038+ with open (supervisord_conf , 'w' ) as f :
2039+ f .write (text )
2040+ try :
2041+ instance .configfile = supervisord_conf
2042+ instance .realize (args = [])
2043+ finally :
2044+ shutil .rmtree (here , ignore_errors = True )
2045+ options = instance .configroot .supervisord
2046+ group = options .process_group_configs [0 ]
2047+ self .assertEqual (group .name , 'cmd' )
2048+ proc = group .process_configs [0 ]
2049+ self .assertEqual (proc .command ,
2050+ os .path .join (here , '/bin/from/program/section' ))
2051+
19992052 def test_options_program_section_expands_here (self ):
20002053 instance = self ._makeOne ()
20012054 text = lstrip ('''
0 commit comments