deer-flow/backend/tests/test_skill_mutation_package_cost.py
Gusanity a759a84201
test: skip POSIX-only skill mutation tests on Windows (#7154)
* test: skip POSIX-only skill mutation tests on Windows

* test: release SQLite fixture connection on Windows

---------

Co-authored-by: unknown <F028@sophon.gd>
2026-10-20 10:03:05 +08:00

28 lines
1.1 KiB
Python

"""Reproducible local capture measurements; not a model/provider benchmark."""
import os
import statistics
import time
import pytest
from deerflow.skills.mutations.assets import capture_package
pytestmark = pytest.mark.skipif(os.name != "posix", reason="package capture requires POSIX filesystem primitives")
@pytest.mark.parametrize("files,size", [(4, 1024), (256, 65535)])
def test_capture_cost_at_typical_and_package_limit(tmp_path, files, size):
(tmp_path / "SKILL.md").write_text("---\nname: example\ndescription: Example\n---\nBody\n", encoding="utf-8")
for index in range(files - 1):
(tmp_path / f"resource-{index:03}.bin").write_bytes(b"x" * size)
timings, digests = [], set()
for _ in range(5):
start = time.perf_counter()
package = capture_package(tmp_path)
digests.add(package.digest)
timings.append((time.perf_counter() - start) * 1000)
assert len(digests) == 1
assert len(package.files) == files
print(f"capture+digest files={files} bytes={sum(len(item.content) for item in package.files)} median_ms={statistics.median(timings):.2f} max_ms={max(timings):.2f}")