Skip to content

Commit f7363f3

Browse files
authored
test: refactor typing tests to align with v3 (#313)
1 parent 46b3ee3 commit f7363f3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/typing/test_typing.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,41 @@
7373
out: |
7474
main:10: error: Argument 1 to "then_return" of "Stub" has incompatible type "str"; expected "int" [arg-type]
7575
76+
- case: mock_class_attribute_get
77+
main: |
78+
from decoy import Decoy
79+
80+
class Dependency():
81+
@property
82+
def value(self) -> int:
83+
return 42
84+
85+
decoy = Decoy()
86+
fake = decoy.mock(cls=Dependency)
87+
88+
decoy.when(fake.value).then_return(42)
89+
decoy.when(fake.value).then_return("wrong-type")
90+
out: |
91+
main:12: error: Argument 1 to "then_return" of "Stub" has incompatible type "str"; expected "int" [arg-type]
92+
93+
- case: mock_class_attribute_set
94+
main: |
95+
from decoy import Decoy
96+
97+
class Dependency():
98+
@property
99+
def value(self) -> int:
100+
return 42
101+
102+
decoy = Decoy()
103+
fake = decoy.mock(cls=Dependency)
104+
prop = decoy.prop(fake.value)
105+
106+
decoy.when(prop.set(42)).then_raise(Exception("oh no"))
107+
decoy.when(prop.set("goodbye")).then_raise(Exception("oh no"))
108+
out: |
109+
main:13: error: Argument 1 to "set" of "Prop" has incompatible type "str"; expected "int" [arg-type]
110+
76111
- case: context_manager_stub_mimics_enter_type
77112
main: |
78113
import contextlib

0 commit comments

Comments
 (0)