@@ -299,3 +299,32 @@ def test_run_with_dotenv_and_command_flags(cli, dotenv_path):
299299
300300 assert result .returncode == 0
301301 assert result .stdout .strip ().startswith ("dotenv, version" )
302+
303+
304+ @pytest .mark .skipif (sys .platform == "win32" , reason = "sh module doesn't support Windows" )
305+ @pytest .mark .parametrize (
306+ "files,file_contents,expected" ,
307+ (
308+ (['.env' ], ['a=1' ], {"a" : "1" }),
309+ (['.env' , '.env.secondary' ], ['a=1' , 'b=2' ], {"a" : "1" , "b" : "2" }),
310+ (['.env' , '.env.secondary' , '.env.extra' ], ['a=1' , 'a=3\n b=2' , 'a=5\n c=3' ], {"a" : "5" , "b" : "2" , "c" : "3" }),
311+ ),
312+ )
313+ def test_run_with_multiple_env_files (tmp_path , files : Sequence [str ], file_contents : Sequence [str ], expected : dict ):
314+ """
315+ Test loading variables from two separate env files using file arguments.
316+
317+ This demonstrates the pattern shown in the README where multiple env files
318+ are loaded (e.g., .env.shared and .env.secret) and all variables from both
319+ files are accessible.
320+ """
321+ with sh .pushd (tmp_path ):
322+ file_args = []
323+ for file_name , content in zip (files , file_contents ):
324+ (tmp_path / file_name ).write_text (content )
325+ file_args .extend (["--file" , file_name ])
326+
327+ for key , value in expected .items ():
328+ result = invoke_sub ([* file_args , "run" , "printenv" , key ])
329+ assert result .stdout .strip () == value
330+
0 commit comments