[PorList] Error if multiple ports are renamed to the same name
This commit is contained in:
parent
8d50f497f1
commit
6a7b3b2259
2 changed files with 23 additions and 0 deletions
|
|
@ -89,6 +89,25 @@ def test_port_list_rename_missing_port_raises() -> None:
|
|||
assert set(pl.ports) == {"A"}
|
||||
|
||||
|
||||
def test_port_list_rename_colliding_targets_raises() -> None:
|
||||
class MyPorts(PortList):
|
||||
def __init__(self) -> None:
|
||||
self._ports = {"A": Port((0, 0), 0), "B": Port((1, 0), 0)}
|
||||
|
||||
@property
|
||||
def ports(self) -> dict[str, Port]:
|
||||
return self._ports
|
||||
|
||||
@ports.setter
|
||||
def ports(self, val: dict[str, Port]) -> None:
|
||||
self._ports = val
|
||||
|
||||
pl = MyPorts()
|
||||
with pytest.raises(PortError, match="Renamed ports would collide"):
|
||||
pl.rename_ports({"A": "C", "B": "C"})
|
||||
assert set(pl.ports) == {"A", "B"}
|
||||
|
||||
|
||||
def test_port_list_add_port_pair_requires_distinct_names() -> None:
|
||||
class MyPorts(PortList):
|
||||
def __init__(self) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue