Skip to content

Commit 9d4c56c

Browse files
randompersona1slhck
authored andcommitted
Added test case for ffmpeg_env()
1 parent 4d75c2b commit 9d4c56c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/test_all.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,27 @@ def test_valid_file_passes_validation(self):
658658
# Should succeed (file exists and has audio)
659659
ffmpeg_normalize_call(["tests/test.mp4", "-n"]) # dry run
660660
# No assertion needed - if validation fails, the command will error
661+
662+
663+
def test_ffmpeg_env():
664+
"""Verify that ffmpeg_env context manager sets environment correctly."""
665+
from ffmpeg_normalize._cmd_utils import ffmpeg_env, _get_ffmpeg_env, CommandRunner
666+
667+
original_env = _get_ffmpeg_env()
668+
assert original_env is None
669+
670+
test_env = os.environ.copy()
671+
test_env.update({"TEST_FFMPEG_ENV_VAR": "12345"})
672+
673+
with ffmpeg_env(test_env):
674+
env_in_context = _get_ffmpeg_env()
675+
assert env_in_context == test_env
676+
# Check that commandrunner uses the env
677+
cmd = CommandRunner().run_command(
678+
[sys.executable, "-c", "import os; print(os.getenv('TEST_FFMPEG_ENV_VAR'))"]
679+
)
680+
assert cmd.get_output().strip() == "12345"
681+
682+
# After context, environment should be reset
683+
env_after = _get_ffmpeg_env()
684+
assert env_after is None

0 commit comments

Comments
 (0)