Skip to content

Commit

Permalink
Merge pull request #209 from unihd-cag/202-snake
Browse files Browse the repository at this point in the history
202 snake
  • Loading branch information
TM90 authored Dec 16, 2022
2 parents 69ceec3 + e29de2d commit 2e23caf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion skillbridge/client/var.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __getattr__(self, item: str) -> 'Var':

def __getitem__(self, item: Union[str, int]) -> 'Var':
if isinstance(item, str):
return Var(f'{self.name}->{snake_to_camel(item)}')
return Var(f'{self.name}->{item}')
return Var(f'nth({item} {self.name})')

def _infix(self, other: Any, op: str) -> 'Var':
Expand Down
8 changes: 8 additions & 0 deletions tests/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ def test_infix():
assert (Var('x') / 123).name == '(x / 123)'
assert (Var('x') | Var('y')).name == 'or(x y )'
assert (Var('x') & Var('y')).name == 'and(x y )'


def test_getattr_performs_conversion():
assert Var('x').abc_def.name == 'x->abcDef'


def test_getitem_does_not_perform_conversion():
assert Var('x')['abc_def'].name == 'x->abc_def'

0 comments on commit 2e23caf

Please sign in to comment.