Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/typing/test_typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,41 @@
out: |
main:10: error: Argument 1 to "then_return" of "Stub" has incompatible type "str"; expected "int" [arg-type]

- case: mock_class_attribute_get
main: |
from decoy import Decoy

class Dependency():
@property
def value(self) -> int:
return 42

decoy = Decoy()
fake = decoy.mock(cls=Dependency)

decoy.when(fake.value).then_return(42)
decoy.when(fake.value).then_return("wrong-type")
out: |
main:12: error: Argument 1 to "then_return" of "Stub" has incompatible type "str"; expected "int" [arg-type]

- case: mock_class_attribute_set
main: |
from decoy import Decoy

class Dependency():
@property
def value(self) -> int:
return 42

decoy = Decoy()
fake = decoy.mock(cls=Dependency)
prop = decoy.prop(fake.value)

decoy.when(prop.set(42)).then_raise(Exception("oh no"))
decoy.when(prop.set("goodbye")).then_raise(Exception("oh no"))
out: |
main:13: error: Argument 1 to "set" of "Prop" has incompatible type "str"; expected "int" [arg-type]

- case: context_manager_stub_mimics_enter_type
main: |
import contextlib
Expand Down