From e29de2d3a90132596c8a598203f20c70c8489942 Mon Sep 17 00:00:00 2001 From: Niels Buwen Date: Fri, 16 Dec 2022 13:35:55 +0100 Subject: [PATCH] Dont perform case conversion in var getitem --- skillbridge/client/var.py | 2 +- tests/test_var.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/skillbridge/client/var.py b/skillbridge/client/var.py index d51eb0c..63129ef 100644 --- a/skillbridge/client/var.py +++ b/skillbridge/client/var.py @@ -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': diff --git a/tests/test_var.py b/tests/test_var.py index 991e7c8..1ac5d7e 100644 --- a/tests/test_var.py +++ b/tests/test_var.py @@ -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'