Files
MoviePilot/tests/test_reflection_signature_contract.py
DDSRem 2de976f6b3 Merge pull request #7050 from DDSRem-Dev/codex-comment-migration
docs: 统一全项目中文注释和结构化契约说明
2026-10-17 19:26:29 +08:00

25 lines
891 B
Python

"""
反射工具公开注解参与运行时签名校验的兼容性回归。
"""
import pytest
from app.foundation.reflection import ObjectUtils
@pytest.mark.parametrize("value, expected", [(lambda: None, True), (len, True), (1, False)])
def test_argument_counter_preserves_runtime_callable_check(value, expected):
"""
参数计数器补齐静态类型后,仍能作为签名校验的目标函数。
"""
assert ObjectUtils.check_signature(ObjectUtils.arguments, value) is expected
def test_signature_checker_preserves_function_annotation():
"""
签名校验器仍保留函数对象注解,同时继续支持检查内建可调用对象。
"""
assert ObjectUtils.check_signature(ObjectUtils.check_signature, lambda: None, 1)
assert not ObjectUtils.check_signature(ObjectUtils.check_signature, len, 1)
assert ObjectUtils.check_signature(len, [])