Skip to content

Commit

Permalink
Implement dir on skill collections
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsbuwen committed Nov 30, 2023
1 parent 270bc22 commit d137d80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions skillbridge/client/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def __setitem__(self, key: Skill, value: Skill) -> None:
def __delitem__(self, item: Skill) -> None:
self._call('remove', item, self)

def __dir__(self) -> list[str]:
response = self._channel.send(self._translator.encode_dir(self._variable))
return self._translator.decode_dir(response)


class RemoteTable(RemoteCollection, MutableMapping[Skill, Skill]):
def __getitem__(self, item: Skill) -> Skill:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def ws() -> Workspace:
except (Exception, ValueError, AssertionError):
warn("Skipping integration tests, because Workspace could not connect", UserWarning)
skip()
raise # this line is unreachable but mypy and pycharm don't know that

return workspace

Expand Down Expand Up @@ -235,3 +234,8 @@ def test_run_script_blocks_when_requested(ws: Workspace) -> None:
assert ws['pyRunScript'](str(here / 'script.py'), args=(variable, '42', '0.25'), block=True)

assert ws['plus'](Var(variable), 1) == 43


def test_form_vectors_have_dir(ws: Workspace) -> None:
form = ws.hi.get_current_form()
assert 'button_layout' in dir(form)

0 comments on commit d137d80

Please sign in to comment.