Update `conftest.py` for `tractor` runtime API changes
Port test fixtures to match `tractor`'s updated registry and channel APIs. Deats, - use `registry_addrs=[reg_addr]` (list) instead of `registry_addr=reg_addr` in `maybe_open_pikerd()`. - `wait_for_actor()` now takes `registry_addr=` kwarg instead of `arbiter_sockaddr=`. - access `portal.chan` (not `.channel`) and unwrap remote addr via `raddr.unwrap()`. - yield `raddr._host`/`raddr._port` instead of tuple-indexing. - drop random port generation; accept `reg_addr` fixture from `tractor`'s builtin pytest plugin. Also, - add `reg_addr: tuple` param to `open_test_pikerd()` fixture (sourced from `tractor._testing.pytest`). - type-narrow `reg_addr` to `tuple[str, int|str]`. - drop unused `import random`. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-coderepair_tests
parent
5a6b63b2ee
commit
d2b539edbd
|
|
@ -92,8 +92,7 @@ def log(
|
|||
@acm
|
||||
async def _open_test_pikerd(
|
||||
tmpconfdir: str,
|
||||
|
||||
reg_addr: tuple[str, int] | None = None,
|
||||
reg_addr: tuple[str, int|str],
|
||||
loglevel: str = 'warning',
|
||||
debug_mode: bool = False,
|
||||
|
||||
|
|
@ -113,16 +112,10 @@ async def _open_test_pikerd(
|
|||
to boot the root actor / tractor runtime.
|
||||
|
||||
'''
|
||||
import random
|
||||
from piker.service import maybe_open_pikerd
|
||||
|
||||
if reg_addr is None:
|
||||
port = random.randint(6e3, 7e3)
|
||||
reg_addr = ('127.0.0.1', port)
|
||||
|
||||
async with (
|
||||
maybe_open_pikerd(
|
||||
registry_addr=reg_addr,
|
||||
registry_addrs=[reg_addr],
|
||||
loglevel=loglevel,
|
||||
|
||||
tractor_runtime_overrides={
|
||||
|
|
@ -139,13 +132,15 @@ async def _open_test_pikerd(
|
|||
|
||||
async with tractor.wait_for_actor(
|
||||
'pikerd',
|
||||
arbiter_sockaddr=reg_addr,
|
||||
registry_addr=reg_addr,
|
||||
) as portal:
|
||||
raddr = portal.channel.raddr
|
||||
assert raddr == reg_addr
|
||||
raddr = portal.chan.raddr
|
||||
uw_raddr: tuple = raddr.unwrap()
|
||||
assert uw_raddr == reg_addr
|
||||
await tractor.pause()
|
||||
yield (
|
||||
raddr[0],
|
||||
raddr[1],
|
||||
raddr._host,
|
||||
raddr._port,
|
||||
portal,
|
||||
service_manager,
|
||||
)
|
||||
|
|
@ -202,7 +197,10 @@ def open_test_pikerd(
|
|||
request: pytest.FixtureRequest,
|
||||
tmp_path: Path,
|
||||
tmpconfdir: Path,
|
||||
|
||||
# XXX from `tractor._testing.pytest` plugin
|
||||
loglevel: str,
|
||||
reg_addr: tuple,
|
||||
):
|
||||
|
||||
tmpconfdir_str: str = str(tmpconfdir)
|
||||
|
|
@ -236,10 +234,13 @@ def open_test_pikerd(
|
|||
# bwitout clobbering each other's config state.
|
||||
tmpconfdir=tmpconfdir_str,
|
||||
|
||||
# bind in level from fixture, which is itself set by
|
||||
# `--ll <value>` cli flag.
|
||||
# NOTE these come verbatim from `tractor`'s builtin plugin!
|
||||
#
|
||||
# per-tpt compat registrar address.
|
||||
reg_addr=reg_addr,
|
||||
# bind in level from fixture.
|
||||
# (can be set with `--ll <value>` flag to `pytest`).
|
||||
loglevel=loglevel,
|
||||
|
||||
debug_mode=debug_mode,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue