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
|
@acm
|
||||||
async def _open_test_pikerd(
|
async def _open_test_pikerd(
|
||||||
tmpconfdir: str,
|
tmpconfdir: str,
|
||||||
|
reg_addr: tuple[str, int|str],
|
||||||
reg_addr: tuple[str, int] | None = None,
|
|
||||||
loglevel: str = 'warning',
|
loglevel: str = 'warning',
|
||||||
debug_mode: bool = False,
|
debug_mode: bool = False,
|
||||||
|
|
||||||
|
|
@ -113,16 +112,10 @@ async def _open_test_pikerd(
|
||||||
to boot the root actor / tractor runtime.
|
to boot the root actor / tractor runtime.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
import random
|
|
||||||
from piker.service import maybe_open_pikerd
|
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 (
|
async with (
|
||||||
maybe_open_pikerd(
|
maybe_open_pikerd(
|
||||||
registry_addr=reg_addr,
|
registry_addrs=[reg_addr],
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
|
|
||||||
tractor_runtime_overrides={
|
tractor_runtime_overrides={
|
||||||
|
|
@ -139,13 +132,15 @@ async def _open_test_pikerd(
|
||||||
|
|
||||||
async with tractor.wait_for_actor(
|
async with tractor.wait_for_actor(
|
||||||
'pikerd',
|
'pikerd',
|
||||||
arbiter_sockaddr=reg_addr,
|
registry_addr=reg_addr,
|
||||||
) as portal:
|
) as portal:
|
||||||
raddr = portal.channel.raddr
|
raddr = portal.chan.raddr
|
||||||
assert raddr == reg_addr
|
uw_raddr: tuple = raddr.unwrap()
|
||||||
|
assert uw_raddr == reg_addr
|
||||||
|
await tractor.pause()
|
||||||
yield (
|
yield (
|
||||||
raddr[0],
|
raddr._host,
|
||||||
raddr[1],
|
raddr._port,
|
||||||
portal,
|
portal,
|
||||||
service_manager,
|
service_manager,
|
||||||
)
|
)
|
||||||
|
|
@ -202,7 +197,10 @@ def open_test_pikerd(
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
tmp_path: Path,
|
tmp_path: Path,
|
||||||
tmpconfdir: Path,
|
tmpconfdir: Path,
|
||||||
|
|
||||||
|
# XXX from `tractor._testing.pytest` plugin
|
||||||
loglevel: str,
|
loglevel: str,
|
||||||
|
reg_addr: tuple,
|
||||||
):
|
):
|
||||||
|
|
||||||
tmpconfdir_str: str = str(tmpconfdir)
|
tmpconfdir_str: str = str(tmpconfdir)
|
||||||
|
|
@ -236,10 +234,13 @@ def open_test_pikerd(
|
||||||
# bwitout clobbering each other's config state.
|
# bwitout clobbering each other's config state.
|
||||||
tmpconfdir=tmpconfdir_str,
|
tmpconfdir=tmpconfdir_str,
|
||||||
|
|
||||||
# bind in level from fixture, which is itself set by
|
# NOTE these come verbatim from `tractor`'s builtin plugin!
|
||||||
# `--ll <value>` cli flag.
|
#
|
||||||
|
# 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,
|
loglevel=loglevel,
|
||||||
|
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue