Skip to content

Commit 6eebc5a

Browse files
authored
fix(spy): handle properties that return primitive types (#132)
1 parent 184ec01 commit 6eebc5a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

decoy/spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def get_signature(self) -> Optional[inspect.Signature]:
7575

7676
try:
7777
return inspect.signature(source)
78-
except TypeError:
78+
except (ValueError, TypeError):
7979
return None
8080

8181
def get_class_type(self) -> Optional[Type[Any]]:

tests/common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def do_the_thing(self, *, flag: bool) -> None:
2222
"""Perform a side-effect without a return value."""
2323
...
2424

25+
@property
26+
def primitive_property(self) -> str:
27+
"""Get a primitive computed property."""
28+
...
29+
2530

2631
class SomeNestedClass:
2732
"""Nested testing class."""

tests/test_spec.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ class GetSignatureSpec(NamedTuple):
118118
return_annotation=str,
119119
),
120120
),
121+
GetSignatureSpec(
122+
subject=Spec(source=SomeClass, name=None).get_child_spec(
123+
"primitive_property"
124+
),
125+
expected_signature=None,
126+
),
121127
GetSignatureSpec(
122128
subject=(
123129
Spec(source=SomeNestedClass, name=None)

0 commit comments

Comments
 (0)