mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-27 12:30:55 +02:00
1b151c5c3e
* compose every test fixture via the builder and run_ffmpeg Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tbcd6VWCiU4BQP1gywPr2a * use loops in tests for ffmpeg stuff --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
2.4 KiB
Python
58 lines
2.4 KiB
Python
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
from facefusion import ffmpeg, ffmpeg_builder, process_manager
|
|
from facefusion.download import conditional_download
|
|
from facefusion.jobs.job_manager import clear_jobs, init_jobs
|
|
from .helper import get_test_example_file, get_test_examples_directory, get_test_jobs_directory, get_test_output_file, is_test_output_file, prepare_test_output_directory
|
|
|
|
|
|
@pytest.fixture(scope = 'module', autouse = True)
|
|
def before_all() -> None:
|
|
process_manager.start()
|
|
conditional_download(get_test_examples_directory(),
|
|
[
|
|
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
|
|
])
|
|
|
|
for frame_number in [ 1, 2 ]:
|
|
ffmpeg.run_ffmpeg(
|
|
ffmpeg_builder.chain(
|
|
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
|
|
[
|
|
'-vframes',
|
|
str(frame_number)
|
|
],
|
|
ffmpeg_builder.set_output(get_test_example_file('target-240p-batch-' + str(frame_number) + '.jpg'))
|
|
)
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope = 'function', autouse = True)
|
|
def before_each() -> None:
|
|
clear_jobs(get_test_jobs_directory())
|
|
init_jobs(get_test_jobs_directory())
|
|
prepare_test_output_directory()
|
|
|
|
|
|
def test_batch_run_targets() -> None:
|
|
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--jobs-path', get_test_jobs_directory(), '--processors', 'face_debugger', '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_file('test-batch-run-targets-{index}.jpg') ]
|
|
|
|
assert subprocess.run(commands).returncode == 0
|
|
assert is_test_output_file('test-batch-run-targets-0.jpg') is True
|
|
assert is_test_output_file('test-batch-run-targets-1.jpg') is True
|
|
assert is_test_output_file('test-batch-run-targets-2.jpg') is False
|
|
|
|
|
|
def test_batch_run_sources_to_targets() -> None:
|
|
commands = [ sys.executable, 'facefusion.py', 'batch-run', '--jobs-path', get_test_jobs_directory(), '-s', get_test_example_file('target-240p-batch-*.jpg'), '-t', get_test_example_file('target-240p-batch-*.jpg'), '-o', get_test_output_file('test-batch-run-sources-to-targets-{index}.jpg') ]
|
|
|
|
assert subprocess.run(commands).returncode == 0
|
|
assert is_test_output_file('test-batch-run-sources-to-targets-0.jpg') is True
|
|
assert is_test_output_file('test-batch-run-sources-to-targets-1.jpg') is True
|
|
assert is_test_output_file('test-batch-run-sources-to-targets-2.jpg') is True
|
|
assert is_test_output_file('test-batch-run-sources-to-targets-3.jpg') is True
|
|
assert is_test_output_file('test-batch-run-sources-to-targets-4.jpg') is False
|