@@ -281,6 +281,33 @@ def test_no_config_file(self):
281281 self .assertEqual (instance .username , 'chris' )
282282 self .assertEqual (instance .password , '123' )
283283
284+ def test_config_file_env (self ):
285+ """Making sure config file can be loaded from env."""
286+ supervisord_conf = os .path .join (tempfile .mkdtemp (), 'supervisord.conf' )
287+ text = lstrip ("""[supervisorctl]
288+ serverurl=http://localhost:9001
289+ username=chris
290+ password=123
291+ """ )
292+ with open (supervisord_conf , 'w' ) as f :
293+ f .write (text )
294+
295+ try :
296+ os .environ ['SUPERVISOR_CONFIG' ] = supervisord_conf
297+ instance = self ._makeOne ()
298+ instance .searchpaths = []
299+ exitcodes = []
300+ instance .exit = lambda x : exitcodes .append (x )
301+ instance .realize (args = [])
302+ finally :
303+ os .environ .pop ('SUPERVISOR_CONFIG' , None )
304+
305+ self .assertEqual (exitcodes , [])
306+ self .assertEqual (instance .interactive , 1 )
307+ self .assertEqual (instance .serverurl , 'http://localhost:9001' )
308+ self .assertEqual (instance .username , 'chris' )
309+ self .assertEqual (instance .password , '123' )
310+
284311 def test_options (self ):
285312 tempdir = tempfile .gettempdir ()
286313 s = lstrip ("""[supervisorctl]
0 commit comments