Skip to content

Commit

Permalink
fix a fragile test and improve SyncNode eq
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier committed Sep 17, 2023
1 parent edbd481 commit 4179922
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Binary file modified asyncua/binary_address_space.pickle
Binary file not shown.
2 changes: 2 additions & 0 deletions asyncua/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ def __init__(self, tloop: ThreadLoop, aio_node: node.Node):
self.tloop = tloop

def __eq__(self, other):
if not isinstance(other, SyncNode):
return False
return other is not None and self.aio_obj == other.aio_obj

def __ne__(self, other):
Expand Down
12 changes: 8 additions & 4 deletions tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ def test_sync_client_get_node(client, idx):
node = client.get_node(85)
assert node == client.nodes.objects
nodes = node.get_children()
assert len(nodes) > 2
assert nodes[0] == client.nodes.server
assert isinstance(nodes[0], SyncNode)
assert len(nodes) > 2

results = node.get_children_by_path([[f"{idx}:MyObject", f"{idx}:MyVariable"]])
child = node.get_child(["0:Server"])
assert child == client.nodes.server

results = node.get_children_by_patdh([[f"{idx}:MyObject", f"{idx}:MyVariable"]])
assert len(results) == 1
vars = results[0]
assert len(vars) == 1
Expand Down Expand Up @@ -177,9 +179,11 @@ def test_sync_server_get_node(server, idx):
assert node == server.nodes.objects
nodes = node.get_children()
assert len(nodes) > 2
assert nodes[0] == server.nodes.server
assert isinstance(nodes[0], SyncNode)

child = node.get_child(["0:Server"])
assert child == server.nodes.server

results = node.get_children_by_path([[f"{idx}:MyObject", f"{idx}:MyVariable"]])
assert len(results) == 1
vars = results[0]
Expand Down

0 comments on commit 4179922

Please sign in to comment.