Files
facefusion/tests/test_cli_face_editor.py
T
Henry RuhsandHarisreedhar 435521dca8 Patch 3.8.3 (#1227)
* bump version

* test every workflow on every processor

* fix low fps bug (#1226)

* significant improve the test

* move partial logic to vision.py

* logic belongs to conditional_get_target_vision_frames

* use avg_frame_rate next to r_frame_rate for fps extraction

* update onnxruntime

* fix upload icon

* improve css

---------

Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com>
2026-09-01 14:42:48 +02:00

56 lines
2.3 KiB
Python

import subprocess
import sys
import pytest
import facefusion.choices
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 facefusion.types import WorkflowStrategy
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/source.jpg',
'https://github.com/facefusion/facefusion-assets/releases/download/examples-3.0.0/target-240p.mp4'
])
ffmpeg.run_ffmpeg(
ffmpeg_builder.chain(
ffmpeg_builder.set_input(get_test_example_file('target-240p.mp4')),
[
'-vframes',
'1'
],
ffmpeg_builder.set_output(get_test_example_file('target-240p.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()
@pytest.mark.parametrize('workflow_strategy', facefusion.choices.workflow_strategies)
def test_edit_face_to_image(workflow_strategy : WorkflowStrategy) -> None:
commands = [ sys.executable, 'facefusion.py', 'headless-run', '--jobs-path', get_test_jobs_directory(), '--workflow-strategy', workflow_strategy, '--processors', 'face_editor', '-t', get_test_example_file('target-240p.jpg'), '-o', get_test_output_file('test-edit-face-to-image.jpg') ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-edit-face-to-image.jpg') is True
@pytest.mark.parametrize('workflow_strategy', facefusion.choices.workflow_strategies)
def test_edit_face_to_video(workflow_strategy : WorkflowStrategy) -> None:
commands = [ sys.executable, 'facefusion.py', 'headless-run', '--jobs-path', get_test_jobs_directory(), '--workflow-strategy', workflow_strategy, '--processors', 'face_editor', '-t', get_test_example_file('target-240p.mp4'), '-o', get_test_output_file('test-edit-face-to-video.mp4'), '--trim-frame-end', '1' ]
assert subprocess.run(commands).returncode == 0
assert is_test_output_file('test-edit-face-to-video.mp4') is True