@@ -1738,6 +1738,20 @@ def test_processes_from_section(self):
1738
1738
self .assertEqual (pconfig .environment ,
1739
1739
{'KEY1' :'val1' , 'KEY2' :'val2' , 'KEY3' :'0' })
1740
1740
1741
+ def test_processes_from_section_environment_with_escaped_chars (self ):
1742
+ instance = self ._makeOne ()
1743
+ text = lstrip ("""\
1744
+ [program:foo]
1745
+ command = /bin/foo
1746
+ environment=VAR_WITH_P="some_value_%%_end"
1747
+ """ )
1748
+ from supervisor .options import UnhosedConfigParser
1749
+ config = UnhosedConfigParser ()
1750
+ config .read_string (text )
1751
+ pconfigs = instance .processes_from_section (config , 'program:foo' , 'bar' )
1752
+ expected = {'VAR_WITH_P' : 'some_value_%_end' }
1753
+ self .assertEqual (pconfigs [0 ].environment , expected )
1754
+
1741
1755
def test_processes_from_section_host_node_name_expansion (self ):
1742
1756
instance = self ._makeOne ()
1743
1757
text = lstrip ("""\
@@ -1933,7 +1947,7 @@ def test_options_with_environment_expansions(self):
1933
1947
nocleanup = %(ENV_SUPD_NOCLEANUP)s
1934
1948
childlogdir = %(ENV_HOME)s
1935
1949
strip_ansi = %(ENV_SUPD_STRIP_ANSI)s
1936
- environment = FAKE_ENV_VAR=/some/path
1950
+ environment = GLOBAL_ENV_VAR=%(ENV_SUPR_ENVIRONMENT_VALUE)s
1937
1951
1938
1952
[inet_http_server]
1939
1953
port=*:%(ENV_HTSRV_PORT)s
@@ -1954,6 +1968,7 @@ def test_options_with_environment_expansions(self):
1954
1968
startretries=%(ENV_CAT1_STARTRETRIES)s
1955
1969
directory=%(ENV_CAT1_DIR)s
1956
1970
umask=%(ENV_CAT1_UMASK)s
1971
+ environment = PROGRAM_ENV_VAR=%(ENV_CAT1_ENVIRONMENT_VALUE)s
1957
1972
""" )
1958
1973
from supervisor import datatypes
1959
1974
from supervisor .options import UnhosedConfigParser
@@ -1964,6 +1979,7 @@ def test_options_with_environment_expansions(self):
1964
1979
'ENV_HTSRV_PORT' : '9210' ,
1965
1980
'ENV_HTSRV_USER' : 'someuser' ,
1966
1981
'ENV_HTSRV_PASS' : 'passwordhere' ,
1982
+ 'ENV_SUPR_ENVIRONMENT_VALUE' : 'from_supervisord_section' ,
1967
1983
'ENV_SUPD_LOGFILE_MAXBYTES' : '51MB' ,
1968
1984
'ENV_SUPD_LOGFILE_BACKUPS' : '10' ,
1969
1985
'ENV_SUPD_LOGLEVEL' : 'info' ,
@@ -1978,6 +1994,7 @@ def test_options_with_environment_expansions(self):
1978
1994
'ENV_CAT1_COMMAND_LOGDIR' : '/path/to/logs' ,
1979
1995
'ENV_CAT1_PRIORITY' : '3' ,
1980
1996
'ENV_CAT1_AUTOSTART' : 'true' ,
1997
+ 'ENV_CAT1_ENVIRONMENT_VALUE' : 'from_program_section' ,
1981
1998
'ENV_CAT1_USER' : 'root' , # resolved to uid
1982
1999
'ENV_CAT1_STDOUT_LOGFILE' : '/tmp/cat.log' ,
1983
2000
'ENV_CAT1_STDOUT_LOGFILE_MAXBYTES' : '78KB' ,
@@ -2043,7 +2060,11 @@ def test_options_with_environment_expansions(self):
2043
2060
self .assertEqual (proc1 .exitcodes , [0 ])
2044
2061
self .assertEqual (proc1 .directory , '/tmp' )
2045
2062
self .assertEqual (proc1 .umask , 2 )
2046
- self .assertEqual (proc1 .environment , dict (FAKE_ENV_VAR = '/some/path' ))
2063
+ expected_env = {
2064
+ 'GLOBAL_ENV_VAR' : 'from_supervisord_section' ,
2065
+ 'PROGRAM_ENV_VAR' : 'from_program_section'
2066
+ }
2067
+ self .assertEqual (proc1 .environment , expected_env )
2047
2068
2048
2069
def test_options_supervisord_section_expands_here (self ):
2049
2070
instance = self ._makeOne ()
0 commit comments