Skip to content

Commit

Permalink
fix(spy): handle properties that return primitive types (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous authored May 10, 2022
1 parent 184ec01 commit 6eebc5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion decoy/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_signature(self) -> Optional[inspect.Signature]:

try:
return inspect.signature(source)
except TypeError:
except (ValueError, TypeError):
return None

def get_class_type(self) -> Optional[Type[Any]]:
Expand Down
5 changes: 5 additions & 0 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def do_the_thing(self, *, flag: bool) -> None:
"""Perform a side-effect without a return value."""
...

@property
def primitive_property(self) -> str:
"""Get a primitive computed property."""
...


class SomeNestedClass:
"""Nested testing class."""
Expand Down
6 changes: 6 additions & 0 deletions tests/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ class GetSignatureSpec(NamedTuple):
return_annotation=str,
),
),
GetSignatureSpec(
subject=Spec(source=SomeClass, name=None).get_child_spec(
"primitive_property"
),
expected_signature=None,
),
GetSignatureSpec(
subject=(
Spec(source=SomeNestedClass, name=None)
Expand Down

0 comments on commit 6eebc5a

Please sign in to comment.