You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/why.md
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ The `Mock` class (and friends) provided by the Python standard library are great
8
8
- Not geared towards mimicking the type annotations of your actual interfaces
9
9
- Geared towards call-then-assert-called test patterns
10
10
11
-
At its core, Decoy uses test fakes that stripped down, slightly more opinionated versions of `Mock` that are designed to work with type annotations.
11
+
At its core, Decoy uses test fakes that are stripped down, slightly more opinionated versions of `Mock` that are designed to work with type annotations.
-`unittest.mock` is a well designed, flexible, and powerful mocking library
47
+
- You may have tests that don't work nicely with Decoy, or legacy code that would be too hard to refactor, and that's OK! Just use [unittest.mock][], instead
48
+
44
49
### Stubs should not return unconditionally
45
50
46
51
- Setting `unittest.mock.Mock::return_value` is unconditional, in that all subsequent calls to that mock will receive that return value, even if they are called incorrectly
@@ -148,7 +153,7 @@ Both of these options have roughly the same upside and downsides:
148
153
- Option 1 separates the input checking from output value, and they appear in reverse chronological order (you define the dependency output before you define the input)
149
154
- Option 2 forces you to create a whole new function and assign it to the `side_effect` value
150
155
- Downside: `MagicMock`is effectively `Any` typed
151
-
-`return_value`and`assert_called_with` are not typed according to the dependency's type definition
156
+
-`return_value`and`assert_called_with` are not typed according to the dependency's type annotations
152
157
- A manual `side_effect`, if typed, needs to be manually typed, which may not match the actual dependency type definition
0 commit comments