Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests #78

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
- run: |
pip install poetry
poetry install --with dev
- run: cp tests/ffmpeg/ffmpeg /usr/local/bin/ffmpeg
- run: poetry run pytest --cov=ffmpy --cov-report xml
- uses: codecov/codecov-action@v4
if: matrix.python-version == 3.12
Expand Down
15 changes: 14 additions & 1 deletion tests/test_cmd_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from ffmpy import FFmpeg
from ffmpy import FFmpeg, FFprobe


@pytest.mark.parametrize(
Expand Down Expand Up @@ -142,3 +142,16 @@ def test_path_with_spaces():
ff = FFmpeg(inputs=inputs, outputs=outputs)
assert ff._cmd == ["ffmpeg", "-i", "/home/ay/file with spaces", "output.ts"]
assert ff.cmd == 'ffmpeg -i "/home/ay/file with spaces" output.ts'


def test_repr():
inputs = {"input.ts": "-f rawvideo"}
outputs = {"output.ts": "-f rawvideo"}
ff = FFmpeg(inputs=inputs, outputs=outputs)
assert repr(ff) == "<'FFmpeg' 'ffmpeg -f rawvideo -i input.ts -f rawvideo output.ts'>"


def test_ffprobe():
inputs = {"input.ts": "-f rawvideo"}
ff = FFprobe(global_options="--verbose", inputs=inputs)
assert repr(ff) == "<'FFprobe' 'ffprobe --verbose -f rawvideo -i input.ts'>"
18 changes: 18 additions & 0 deletions tests/test_cmd_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

from ffmpy import FFExecutableNotFoundError, FFmpeg, FFRuntimeError

FFMPEG_PATH = os.path.join(os.path.dirname(__file__), "ffmpeg")
os.environ["PATH"] = FFMPEG_PATH + os.pathsep + os.environ["PATH"]


def test_invalid_executable_path():
ff = FFmpeg(executable="/tmp/foo/bar/ffmpeg")
Expand All @@ -16,6 +19,21 @@ def test_invalid_executable_path():
assert str(exc_info.value) == "Executable '/tmp/foo/bar/ffmpeg' not found"


def test_other_oserror():
executable = os.path.join(FFMPEG_PATH, "ffmpeg.go")
ff = FFmpeg(executable=executable)
with pytest.raises(PermissionError) as exc_info:
ff.run()
assert str(exc_info.value).startswith("[Errno 13] Permission denied")


def test_executable_full_path():
executable = os.path.join(FFMPEG_PATH, "ffmpeg")
ff = FFmpeg(executable=executable)
ff.run()
assert ff.cmd == executable


def test_no_redirection():
global_options = "--stdin none --stdout oneline --stderr multiline --exit-code 0"
ff = FFmpeg(global_options=global_options)
Expand Down