-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CHANGES.txt
283 lines (174 loc) · 9.59 KB
/
CHANGES.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
MOCKITO CHANGE LOG
==================
Release 1.5.0
-------------------------------
- @Oracking fixed `expect` to support a string as its first argument. All
other functions supported that already. E.g.
::
expect('os.path', times=2).exists(...).thenReturn(True)
Release 1.4.0 (August 25, 2022)
-------------------------------
- @avandierast implemented `thenCallOriginalImplementation`. See #60
::
# Let `os.path.exists` use the real filesystem (often needed when
# the testing framework needs itself a working `os.path.exists`
# implementation) *but* fake a `.flake8` file.
when(os.path).exists(...).thenCallOriginalImplementation()
when(os.path).exists('.flake8').thenReturn(True)
Release 1.3.5 (August 18, 2022)
-------------------------------
- Restore compatibility with Python 2.7
Release 1.3.3 (June 23, 2022)
-----------------------------
- Hotfix: Correctly unstub methods extracted to the module level, for example ``random.randint()`` et.al. from the standard library. See #53
Release 1.3.2 (June 23, 2022)
-----------------------------
- Let `mock(spec=SomeClass)` work just as `mock(SomeClass)`
Release 1.3.1 (June 14, 2022)
-----------------------------
- Reimplement `captor` to capture only during execution phase of a test.
Release 1.3.0 (December 3, 2021)
--------------------------------
- Teach `captor` to remember all used values (@shashankrnr32). E.g.
::
arg = captor()
mock.do_something(123)
mock.do_something(456)
verify(mock).do_something(arg)
assert arg.all_values == [123, 456]
Release 1.2.2 (September 9, 2020)
---------------------------------
- Fix typo in ``spy2`` doc
Release 1.2.1 (February 19, 2020)
---------------------------------
- @nielsvaneck fixed how we can lookup inherited classmethods.
Release 1.2.0 (November 25, 2019)
---------------------------------
- Code base now is python 3 compatible. No 2to3 anymore.
- Fine tune error messages on unexpected calls or verifications. E.g. if you expect ``when(dog).bark('Wuff')`` but on call time do ``dog.bark('Wufff')``. Likewise, if you call ``dog.bark('Miau')`` and then ``verify(dog).bark('Maui')``.
- @felixonmars fixed a small compatibility issue with python 3.8
- Mocking properties has become a bit easier. (#26) E.g.
::
prop = mock()
when(prop).__get__(...).thenReturn(23)
m = mock({'name': prop})
Release 1.1.1 (August 28, 2018)
-------------------------------
- Fix: The context manager (``with``) has now a proper implementation
- Fix: Calling ``patch`` with two arguments can now be used with ``with``
- Fix: Do not treat the placeholder arguments (Ellipsis, args, kwargs) as special on call time anymore. (T.i. they only have a meaning when stubbing or verifying.)
- Enhancement: Changed some truthy or equality tests to identity (``is``) tests. This reduces edge-cases where some user object defines ``__eq__`` or ``__bool__``. (Hello _numpy_!)
Release 1.1.0 (May 2, 2018)
---------------------------
- Added ``forget_invocations`` function. Thanks to @maximkulkin
This is generally useful if you already call mocks during your setup routine.
Now you could call ``forget_invocations`` at the end of your setup, and
have a clean 'recording' for your actual test code. T.i. you don't have
to count the invocations from your setup code anymore.
Release 1.0.12 (June 3, 2017)
-----------------------------
- Better error messages for failed verifications. By @lwoydziak
Release 1.0.7 - 1.0.10 (January 31 - February 2, 2017)
------------------------------------------------------
- ``verifyZeroInteractions`` implemented. This is actually a *breaking change*, because ``verifyZeroInteractions`` was an alias for ``verifyNoMoreInteractions`` (sic!). If you used it, just call the other function.
- ``verifyStubbedInvocationsAreUsed`` implemented. This is meant to be called right before an ``unstub`` and should improve long time maintenance. It doesn't help during design time. Note that `pytest-mockito` automatically calls this for you.
- All `verify*` functions now warn you if you pass in an object which was never stubbed.
Release 1.0.0 - 1.0.5 (January 24 - 27, 2017)
---------------------------------------------
This is a major update; mostly because of internal code reorganization (`imports`) it cannot be guaranteed that this will not break for you. Though if you just used the public API you should be fine. None of the vintage old tests have been removed and they at least pass.
In general unclassified imports (``from mocktio import *``) are not recommended. But if you did, we do not export `Mock` anymore. `Mock` has been deprecated long ago and is now for internal use only. You must use `mock`.
Another important change is, that *mockito*'s strict mode is far more strict than before. We now generally try to match the signature of the target method
with your usage. Usually this should help you find bugs in your code, because
it will make it easier to spot changing interfaces.
- ``mock``, ``when``, ``verify`` return mostly empty objects. It is unlikely to have a method_name clash.
- Specced mocks ``instance = mock(Class)`` will pass isinstance tests like ``isinstance(instance, Class)``
- For ``when`` and ``verify`` the function signature or argument matchers can be greatly simplified. E.g. ``when(requests).get(...).thenReturn('OK')`` will match any argument you pass in. There are ``args`` and ``kwargs`` matchers as well. So ``when(requests).get('https://...', **kwargs).thenReturn(...)`` will make an exact match on the first argument, the url, and ignore all the headers and other stuff.
- Mocks can be preconfigured: ``mock({'text': 'OK'})``. For specced mocks this would be e.g. ``mock({'text': 'OK'}, spec=requests.Response)``.
- If you mock or patch an object, the function signatures will be matched. So::
def foo(a, b=1): ...
when(main).foo(12) # will pass
when(main).foo(c=13) # will raise immediately
- Mock Dummies are now callable::
m = mock()
m(1, 2)
verify(m).__call__(...)
- ``Mock()`` is now an implementation detail; it is **not** exported anymore. Use ``mock()``.
- You can unstub individual patched objects ``unstub(obj)``. (Before it was all or nothing.)
- Added basic context manager support when using ``when``. Note that ``verify`` has to be called within the with context.
::
with when(rex).waggle().thenReturn('Yup'):
assert rex.waggle() == 'Yup'
verify(rex).waggle()
- Aliased ``any_`` to ``ANY``, ``args`` to ``ARGS`` and ``kwargs`` to ``KWARGS``. You can use python's builtin ``any`` as a stand in for ``ANY``.
- As a convenience you can use our ``any_`` matcher like a type instead of ``any_()``::
dummy(1)
verify(dummy).__call__(ANY)
- Added ``when2``, ``expect``, ``spy2``
- Make the mocked function (replacement) more inspectable. Copy `__doc__`, `__name__` etc.
- You can configure magic methods on mocks::
dummy = mock()
when(dummy).__getitem__(1).thenReturn(2)
assert dummy[1] == 2
Release 0.7.1 (December 27, 2016)
---------------------------------
- Fix: Allow ``verifyNoMoreInteractions`` call for real (stubbed) objects
Release 0.7.0 (July 15, 2016)
-----------------------------
- Added a ton of new argument matchers. Namely::
'and_', 'or_', 'not_', 'eq', 'neq', 'lt', 'lte', 'gt', 'gte',
'arg_that', 'matches', 'captor'
- Aliases ``any`` matcher to ``any_`` because it's a builtin.
- Fixes an issue where mockito could not correctly verify your function invocations, if you grabbed a method from its object and used it ('detached') as a plain function::
m = mock()
f = m.foo # detach
f(1, 2) # pass it around and use it like a function
f(2, 3)
verify(m).foo(...) # finally verify interactions
Thank you @maximkulkin
Release 0.6.1 (May 20, 2016)
----------------------------
- Added ``thenAnswer(callable)``. The callable will be called to compute the answer the stubbed method will return. For that it will receive the arguments of the caller::
m = mock()
when(m).do_times(any(), any()).thenAnswer(lambda one, two: one * two)
self.assertEquals(20, m.do_times(5, 4))
Thank you @stubbsd
Release 0.6.0 (April 25, 2016)
------------------------------
- Print keyword arguments nicely.
- Be very forgiving about return values and assume None as default. T.i. ``when(Dog).bark('Miau').thenReturn()`` is enough to return None.
- Make keyword argument order unimportant.
- BREAKING CHANGE: Throw early when calling not expected methods in strict mode.
Release 0.5.3 (April 23, 2016)
------------------------------
- Remove hard coded distribute setup files.
Release 0.5.1 (August 4, 2010)
------------------------------
BUG Fixes:
- Fixed issue #9 [http://bitbucket.org/szczepiq/mockito-python/issue/9] : Generating stubs from classes caused method to be replaced in original classes.
Release 0.5.0 (July 26, 2010)
-----------------------------
API Changes:
- Added possibility to spy on real objects.
- Added "never" syntactic sugar for verifications.
BUG Fixes:
- Fixed issue with named arguments matching.
Other Changes:
- Python 2.7 support
- Deprecated APIs now generate deprecation warnings.
Release 0.4.0 (July 2, 2010)
----------------------------
API Changes:
- Added possibility to verify invocations in order.
BUG Fixes:
- Fixed issue with installing mockito from egg without distribute installed.
Release 0.3.1
-------------
Bug-fix release.
Bug Fixes:
- Fixed annoying issue #8 [http://bitbucket.org/szczepiq/mockito-python/issue/8]
Release 0.3.0
-------------
API Changes:
- Renamed mock creation method from "Mock" (upper "M") to "mock". Old name stays for compatibility until 1.0 release.
Other Changes:
- Official Python3 support via distutils + 2to3.