Files
pm3py/tests/test_sync_proxy.py
michael 739e28e113 feat(client): make dir()/help() work through _SyncProxy
The sync REPL proxy forwarded methods via __getattr__, so dir()/tab-completion never saw them and the sync wrapper reported (*args, **kwargs) instead of the real signature. Add __dir__ delegating to the wrapped target, and decorate the async wrapper with functools.wraps so inspect.signature()/help() report the real params + docstring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 00:20:03 -07:00

32 lines
982 B
Python

"""_SyncProxy introspection: dir() and help()/signature must work through the proxy."""
import asyncio
import inspect
from unittest.mock import AsyncMock
from pm3py.core.client import _SyncProxy
from pm3py.core.hf_iso15 import HF15Commands
def _proxy():
return _SyncProxy(HF15Commands(AsyncMock()), asyncio.new_event_loop())
def test_dir_surfaces_target_methods():
d = dir(_proxy())
for name in ("scan", "rdbl", "wrbl", "raw_inventory", "sniff"):
assert name in d, f"{name} missing from dir(proxy)"
def test_wrapped_method_preserves_signature():
proxy = _proxy()
# signature must be the real params, not the wrapper's (*args, **kwargs)
sig = inspect.signature(proxy.rdbl)
assert list(sig.parameters) == ["block", "uid"]
assert sig.parameters["uid"].default is None
def test_wrapped_method_preserves_doc_and_name():
proxy = _proxy()
assert proxy.rdbl.__name__ == "rdbl"
assert proxy.rdbl.__doc__ == "Read a single block."