Fix `test_registrar_merge_binds_union` for UDS collision

`get_random()` can produce the same UDS filename for a given
pid+actor-state, so the "disjoint addrs" premise doesn't always hold.
Gate the `len(bound) >= 2` assertion on whether the registry and bind
addrs actually differ via `expect_disjoint`.

Also,
- drop unused `partial` import

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
subint_spawner_backend
Gud Boi 2026-04-14 15:16:57 -04:00
parent 7b04b2cdfc
commit cd287c7e93
1 changed files with 12 additions and 4 deletions

View File

@ -9,8 +9,6 @@ bind-address selection in `_root.py`:
3. Explicit bind given -> wraps via `wrap_address()` and uses them 3. Explicit bind given -> wraps via `wrap_address()` and uses them
''' '''
from functools import partial
import pytest import pytest
import trio import trio
import tractor import tractor
@ -283,6 +281,15 @@ def test_registrar_merge_binds_union(
) )
bind_addrs = [rando.unwrap()] bind_addrs = [rando.unwrap()]
# NOTE: for UDS, `get_random()` produces the same
# filename for the same pid+actor-state, so the
# "disjoint" premise only holds when the addrs
# actually differ (always true for TCP, may
# collide for UDS).
expect_disjoint: bool = (
tuple(reg_addr) != rando.unwrap()
)
async def _main(): async def _main():
async with tractor.open_root_actor( async with tractor.open_root_actor(
registry_addrs=[reg_addr], registry_addrs=[reg_addr],
@ -295,8 +302,9 @@ def test_registrar_merge_binds_union(
bound = actor.accept_addrs bound = actor.accept_addrs
bound_w = _bound_wrapped(actor) bound_w = _bound_wrapped(actor)
# must have at least 2 (registry + bind) if expect_disjoint:
assert len(bound) >= 2 # must have at least 2 (registry + bind)
assert len(bound) >= 2
# registry addr must appear in bound set # registry addr must appear in bound set
assert reg_wrapped in bound_w assert reg_wrapped in bound_w