1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/python/mock-1.0.0/docs/changelog.txt Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,725 @@ 1.4 +.. currentmodule:: mock 1.5 + 1.6 + 1.7 +CHANGELOG 1.8 +========= 1.9 + 1.10 +2012/10/07 Version 1.0.0 1.11 +------------------------ 1.12 + 1.13 +No changes since 1.0.0 beta 1. This version has feature parity with 1.14 +`unittest.mock 1.15 +<http://docs.python.org/py3k/library/unittest.mock.html#module-unittest.mock>`_ 1.16 +in Python 3.3. 1.17 + 1.18 +Full list of changes since 0.8: 1.19 + 1.20 +* `mocksignature`, along with the `mocksignature` argument to `patch`, removed 1.21 +* Support for deleting attributes (accessing deleted attributes will raise an 1.22 + `AttributeError`) 1.23 +* Added the `mock_open` helper function for mocking the builtin `open` 1.24 +* `__class__` is assignable, so a mock can pass an `isinstance` check without 1.25 + requiring a spec 1.26 +* Addition of `PropertyMock`, for mocking properties 1.27 +* `MagicMocks` made unorderable by default (in Python 3). The comparison 1.28 + methods (other than equality and inequality) now return `NotImplemented` 1.29 +* Propagate traceback info to support subclassing of `_patch` by other 1.30 + libraries 1.31 +* `create_autospec` works with attributes present in results of `dir` that 1.32 + can't be fetched from the object's class. Contributed by Konstantine Rybnikov 1.33 +* Any exceptions in an iterable `side_effect` will be raised instead of 1.34 + returned 1.35 +* In Python 3, `create_autospec` now supports keyword only arguments 1.36 +* Added `patch.stopall` method to stop all active patches created by `start` 1.37 +* BUGFIX: calling `MagicMock.reset_mock` wouldn't reset magic method mocks 1.38 +* BUGFIX: calling `reset_mock` on a `MagicMock` created with autospec could 1.39 + raise an exception 1.40 +* BUGFIX: passing multiple spec arguments to patchers (`spec` , `spec_set` and 1.41 + `autospec`) had unpredictable results, now it is an error 1.42 +* BUGFIX: using `spec=True` *and* `create=True` as arguments to patchers could 1.43 + result in using `DEFAULT` as the spec. Now it is an error instead 1.44 +* BUGFIX: using `spec` or `autospec` arguments to patchers, along with 1.45 + `spec_set=True` did not work correctly 1.46 +* BUGFIX: using an object that evaluates to False as a spec could be ignored 1.47 +* BUGFIX: a list as the `spec` argument to a patcher would always result in a 1.48 + non-callable mock. Now if `__call__` is in the spec the mock is callable 1.49 + 1.50 + 1.51 +2012/07/13 Version 1.0.0 beta 1 1.52 +-------------------------------- 1.53 + 1.54 +* Added `patch.stopall` method to stop all active patches created by `start` 1.55 +* BUGFIX: calling `MagicMock.reset_mock` wouldn't reset magic method mocks 1.56 +* BUGFIX: calling `reset_mock` on a `MagicMock` created with autospec could 1.57 + raise an exception 1.58 + 1.59 + 1.60 +2012/05/04 Version 1.0.0 alpha 2 1.61 +-------------------------------- 1.62 + 1.63 +* `PropertyMock` attributes are now standard `MagicMocks` 1.64 +* `create_autospec` works with attributes present in results of `dir` that 1.65 + can't be fetched from the object's class. Contributed by Konstantine Rybnikov 1.66 +* Any exceptions in an iterable `side_effect` will be raised instead of 1.67 + returned 1.68 +* In Python 3, `create_autospec` now supports keyword only arguments 1.69 + 1.70 + 1.71 +2012/03/25 Version 1.0.0 alpha 1 1.72 +-------------------------------- 1.73 + 1.74 +The standard library version! 1.75 + 1.76 +* `mocksignature`, along with the `mocksignature` argument to `patch`, removed 1.77 +* Support for deleting attributes (accessing deleted attributes will raise an 1.78 + `AttributeError`) 1.79 +* Added the `mock_open` helper function for mocking the builtin `open` 1.80 +* `__class__` is assignable, so a mock can pass an `isinstance` check without 1.81 + requiring a spec 1.82 +* Addition of `PropertyMock`, for mocking properties 1.83 +* `MagicMocks` made unorderable by default (in Python 3). The comparison 1.84 + methods (other than equality and inequality) now return `NotImplemented` 1.85 +* Propagate traceback info to support subclassing of `_patch` by other 1.86 + libraries 1.87 +* BUGFIX: passing multiple spec arguments to patchers (`spec` , `spec_set` and 1.88 + `autospec`) had unpredictable results, now it is an error 1.89 +* BUGFIX: using `spec=True` *and* `create=True` as arguments to patchers could 1.90 + result in using `DEFAULT` as the spec. Now it is an error instead 1.91 +* BUGFIX: using `spec` or `autospec` arguments to patchers, along with 1.92 + `spec_set=True` did not work correctly 1.93 +* BUGFIX: using an object that evaluates to False as a spec could be ignored 1.94 +* BUGFIX: a list as the `spec` argument to a patcher would always result in a 1.95 + non-callable mock. Now if `__call__` is in the spec the mock is callable 1.96 + 1.97 + 1.98 +2012/02/13 Version 0.8.0 1.99 +------------------------ 1.100 + 1.101 +The only changes since 0.8rc2 are: 1.102 + 1.103 +* Improved repr of :data:`sentinel` objects 1.104 +* :data:`ANY` can be used for comparisons against :data:`call` objects 1.105 +* The return value of `MagicMock.__iter__` method can be set to 1.106 + any iterable and isn't required to be an iterator 1.107 + 1.108 +Full List of changes since 0.7: 1.109 + 1.110 +mock 0.8.0 is the last version that will support Python 2.4. 1.111 + 1.112 +* Addition of :attr:`~Mock.mock_calls` list for *all* calls (including magic 1.113 + methods and chained calls) 1.114 +* :func:`patch` and :func:`patch.object` now create a :class:`MagicMock` 1.115 + instead of a :class:`Mock` by default 1.116 +* The patchers (`patch`, `patch.object` and `patch.dict`), plus `Mock` and 1.117 + `MagicMock`, take arbitrary keyword arguments for configuration 1.118 +* New mock method :meth:`~Mock.configure_mock` for setting attributes and 1.119 + return values / side effects on the mock and its attributes 1.120 +* New mock assert methods :meth:`~Mock.assert_any_call` and 1.121 + :meth:`~Mock.assert_has_calls` 1.122 +* Implemented :ref:`auto-speccing` (recursive, lazy speccing of mocks with 1.123 + mocked signatures for functions/methods), as the `autospec` argument to 1.124 + `patch` 1.125 +* Added the :func:`create_autospec` function for manually creating 1.126 + 'auto-specced' mocks 1.127 +* :func:`patch.multiple` for doing multiple patches in a single call, using 1.128 + keyword arguments 1.129 +* Setting :attr:`~Mock.side_effect` to an iterable will cause calls to the mock 1.130 + to return the next value from the iterable 1.131 +* New `new_callable` argument to `patch` and `patch.object` allowing you to 1.132 + pass in a class or callable object (instead of `MagicMock`) that will be 1.133 + called to replace the object being patched 1.134 +* Addition of :class:`NonCallableMock` and :class:`NonCallableMagicMock`, mocks 1.135 + without a `__call__` method 1.136 +* Addition of :meth:`~Mock.mock_add_spec` method for adding (or changing) a 1.137 + spec on an existing mock 1.138 +* Protocol methods on :class:`MagicMock` are magic mocks, and are created 1.139 + lazily on first lookup. This means the result of calling a protocol method is 1.140 + a `MagicMock` instead of a `Mock` as it was previously 1.141 +* Addition of :meth:`~Mock.attach_mock` method 1.142 +* Added :data:`ANY` for ignoring arguments in :meth:`~Mock.assert_called_with` 1.143 + calls 1.144 +* Addition of :data:`call` helper object 1.145 +* Improved repr for mocks 1.146 +* Improved repr for :attr:`Mock.call_args` and entries in 1.147 + :attr:`Mock.call_args_list`, :attr:`Mock.method_calls` and 1.148 + :attr:`Mock.mock_calls` 1.149 +* Improved repr for :data:`sentinel` objects 1.150 +* `patch` lookup is done at use time not at decoration time 1.151 +* In Python 2.6 or more recent, `dir` on a mock will report all the dynamically 1.152 + created attributes (or the full list of attributes if there is a spec) as 1.153 + well as all the mock methods and attributes. 1.154 +* Module level :data:`FILTER_DIR` added to control whether `dir(mock)` filters 1.155 + private attributes. `True` by default. 1.156 +* `patch.TEST_PREFIX` for controlling how patchers recognise test methods when 1.157 + used to decorate a class 1.158 +* Support for using Java exceptions as a :attr:`~Mock.side_effect` on Jython 1.159 +* `Mock` call lists (`call_args_list`, `method_calls` & `mock_calls`) are now 1.160 + custom list objects that allow membership tests for "sub lists" and have 1.161 + a nicer representation if you `str` or `print` them 1.162 +* Mocks attached as attributes or return values to other mocks have calls 1.163 + recorded in `method_calls` and `mock_calls` of the parent (unless a name is 1.164 + already set on the child) 1.165 +* Improved failure messages for `assert_called_with` and 1.166 + `assert_called_once_with` 1.167 +* The return value of the :class:`MagicMock` `__iter__` method can be set to 1.168 + any iterable and isn't required to be an iterator 1.169 +* Added the Mock API (`assert_called_with` etc) to functions created by 1.170 + :func:`mocksignature` 1.171 +* Tuples as well as lists can be used to specify allowed methods for `spec` & 1.172 + `spec_set` arguments 1.173 +* Calling `stop` on an unstarted patcher fails with a more meaningful error 1.174 + message 1.175 +* Renamed the internal classes `Sentinel` and `SentinelObject` to prevent abuse 1.176 +* BUGFIX: an error creating a patch, with nested patch decorators, won't leave 1.177 + patches in place 1.178 +* BUGFIX: `__truediv__` and `__rtruediv__` not available as magic methods on 1.179 + mocks in Python 3 1.180 +* BUGFIX: `assert_called_with` / `assert_called_once_with` can be used with 1.181 + `self` as a keyword argument 1.182 +* BUGFIX: when patching a class with an explicit spec / spec_set (not a 1.183 + boolean) it applies "spec inheritance" to the return value of the created 1.184 + mock (the "instance") 1.185 +* BUGFIX: remove the `__unittest` marker causing traceback truncation 1.186 +* Removal of deprecated `patch_object` 1.187 +* Private attributes `_name`, `_methods`, '_children', `_wraps` and `_parent` 1.188 + (etc) renamed to reduce likelihood of clash with user attributes. 1.189 +* Added license file to the distribution 1.190 + 1.191 + 1.192 +2012/01/10 Version 0.8.0 release candidate 2 1.193 +-------------------------------------------- 1.194 + 1.195 +* Removed the `configure` keyword argument to `create_autospec` and allow 1.196 + arbitrary keyword arguments (for the `Mock` constructor) instead 1.197 +* Fixed `ANY` equality with some types in `assert_called_with` calls 1.198 +* Switched to a standard Sphinx theme (compatible with 1.199 + `readthedocs.org <http://mock.readthedocs.org>`_) 1.200 + 1.201 + 1.202 +2011/12/29 Version 0.8.0 release candidate 1 1.203 +-------------------------------------------- 1.204 + 1.205 +* `create_autospec` on the return value of a mocked class will use `__call__` 1.206 + for the signature rather than `__init__` 1.207 +* Performance improvement instantiating `Mock` and `MagicMock` 1.208 +* Mocks used as magic methods have the same type as their parent instead of 1.209 + being hardcoded to `MagicMock` 1.210 + 1.211 +Special thanks to Julian Berman for his help with diagnosing and improving 1.212 +performance in this release. 1.213 + 1.214 + 1.215 +2011/10/09 Version 0.8.0 beta 4 1.216 +------------------------------- 1.217 + 1.218 +* `patch` lookup is done at use time not at decoration time 1.219 +* When attaching a Mock to another Mock as a magic method, calls are recorded 1.220 + in mock_calls 1.221 +* Addition of `attach_mock` method 1.222 +* Renamed the internal classes `Sentinel` and `SentinelObject` to prevent abuse 1.223 +* BUGFIX: various issues around circular references with mocks (setting a mock 1.224 + return value to be itself etc) 1.225 + 1.226 + 1.227 +2011/08/15 Version 0.8.0 beta 3 1.228 +------------------------------- 1.229 + 1.230 +* Mocks attached as attributes or return values to other mocks have calls 1.231 + recorded in `method_calls` and `mock_calls` of the parent (unless a name is 1.232 + already set on the child) 1.233 +* Addition of `mock_add_spec` method for adding (or changing) a spec on an 1.234 + existing mock 1.235 +* Improved repr for `Mock.call_args` and entries in `Mock.call_args_list`, 1.236 + `Mock.method_calls` and `Mock.mock_calls` 1.237 +* Improved repr for mocks 1.238 +* BUGFIX: minor fixes in the way `mock_calls` is worked out, 1.239 + especially for "intermediate" mocks in a call chain 1.240 + 1.241 + 1.242 +2011/08/05 Version 0.8.0 beta 2 1.243 +------------------------------- 1.244 + 1.245 +* Setting `side_effect` to an iterable will cause calls to the mock to return 1.246 + the next value from the iterable 1.247 +* Added `assert_any_call` method 1.248 +* Moved `assert_has_calls` from call lists onto mocks 1.249 +* BUGFIX: `call_args` and all members of `call_args_list` are two tuples of 1.250 + `(args, kwargs)` again instead of three tuples of `(name, args, kwargs)` 1.251 + 1.252 + 1.253 +2011/07/25 Version 0.8.0 beta 1 1.254 +------------------------------- 1.255 + 1.256 +* `patch.TEST_PREFIX` for controlling how patchers recognise test methods when 1.257 + used to decorate a class 1.258 +* `Mock` call lists (`call_args_list`, `method_calls` & `mock_calls`) are now 1.259 + custom list objects that allow membership tests for "sub lists" and have 1.260 + an `assert_has_calls` method for unordered call checks 1.261 +* `callargs` changed to *always* be a three-tuple of `(name, args, kwargs)` 1.262 +* Addition of `mock_calls` list for *all* calls (including magic methods and 1.263 + chained calls) 1.264 +* Extension of `call` object to support chained calls and `callargs` for better 1.265 + comparisons with or without names. `call` object has a `call_list` method for 1.266 + chained calls 1.267 +* Added the public `instance` argument to `create_autospec` 1.268 +* Support for using Java exceptions as a `side_effect` on Jython 1.269 +* Improved failure messages for `assert_called_with` and 1.270 + `assert_called_once_with` 1.271 +* Tuples as well as lists can be used to specify allowed methods for `spec` & 1.272 + `spec_set` arguments 1.273 +* BUGFIX: Fixed bug in `patch.multiple` for argument passing when creating 1.274 + mocks 1.275 +* Added license file to the distribution 1.276 + 1.277 + 1.278 +2011/07/16 Version 0.8.0 alpha 2 1.279 +-------------------------------- 1.280 + 1.281 +* `patch.multiple` for doing multiple patches in a single call, using keyword 1.282 + arguments 1.283 +* New `new_callable` argument to `patch` and `patch.object` allowing you to 1.284 + pass in a class or callable object (instead of `MagicMock`) that will be 1.285 + called to replace the object being patched 1.286 +* Addition of `NonCallableMock` and `NonCallableMagicMock`, mocks without a 1.287 + `__call__` method 1.288 +* Mocks created by `patch` have a `MagicMock` as the `return_value` where a 1.289 + class is being patched 1.290 +* `create_autospec` can create non-callable mocks for non-callable objects. 1.291 + `return_value` mocks of classes will be non-callable unless the class has 1.292 + a `__call__` method 1.293 +* `autospec` creates a `MagicMock` without a spec for properties and slot 1.294 + descriptors, because we don't know the type of object they return 1.295 +* Removed the "inherit" argument from `create_autospec` 1.296 +* Calling `stop` on an unstarted patcher fails with a more meaningful error 1.297 + message 1.298 +* BUGFIX: an error creating a patch, with nested patch decorators, won't leave 1.299 + patches in place 1.300 +* BUGFIX: `__truediv__` and `__rtruediv__` not available as magic methods on 1.301 + mocks in Python 3 1.302 +* BUGFIX: `assert_called_with` / `assert_called_once_with` can be used with 1.303 + `self` as a keyword argument 1.304 +* BUGFIX: autospec for functions / methods with an argument named self that 1.305 + isn't the first argument no longer broken 1.306 +* BUGFIX: when patching a class with an explicit spec / spec_set (not a 1.307 + boolean) it applies "spec inheritance" to the return value of the created 1.308 + mock (the "instance") 1.309 +* BUGFIX: remove the `__unittest` marker causing traceback truncation 1.310 + 1.311 + 1.312 +2011/06/14 Version 0.8.0 alpha 1 1.313 +-------------------------------- 1.314 + 1.315 +mock 0.8.0 is the last version that will support Python 2.4. 1.316 + 1.317 +* The patchers (`patch`, `patch.object` and `patch.dict`), plus `Mock` and 1.318 + `MagicMock`, take arbitrary keyword arguments for configuration 1.319 +* New mock method `configure_mock` for setting attributes and return values / 1.320 + side effects on the mock and its attributes 1.321 +* In Python 2.6 or more recent, `dir` on a mock will report all the dynamically 1.322 + created attributes (or the full list of attributes if there is a spec) as 1.323 + well as all the mock methods and attributes. 1.324 +* Module level `FILTER_DIR` added to control whether `dir(mock)` filters 1.325 + private attributes. `True` by default. Note that `vars(Mock())` can still be 1.326 + used to get all instance attributes and `dir(type(Mock())` will still return 1.327 + all the other attributes (irrespective of `FILTER_DIR`) 1.328 +* `patch` and `patch.object` now create a `MagicMock` instead of a `Mock` by 1.329 + default 1.330 +* Added `ANY` for ignoring arguments in `assert_called_with` calls 1.331 +* Addition of `call` helper object 1.332 +* Protocol methods on `MagicMock` are magic mocks, and are created lazily on 1.333 + first lookup. This means the result of calling a protocol method is a 1.334 + MagicMock instead of a Mock as it was previously 1.335 +* Added the Mock API (`assert_called_with` etc) to functions created by 1.336 + `mocksignature` 1.337 +* Private attributes `_name`, `_methods`, '_children', `_wraps` and `_parent` 1.338 + (etc) renamed to reduce likelihood of clash with user attributes. 1.339 +* Implemented auto-speccing (recursive, lazy speccing of mocks with mocked 1.340 + signatures for functions/methods) 1.341 + 1.342 + Limitations: 1.343 + 1.344 + - Doesn't mock magic methods or attributes (it creates MagicMocks, so the 1.345 + magic methods are *there*, they just don't have the signature mocked nor 1.346 + are attributes followed) 1.347 + - Doesn't mock function / method attributes 1.348 + - Uses object traversal on the objects being mocked to determine types - so 1.349 + properties etc may be triggered 1.350 + - The return value of mocked classes (the 'instance') has the same call 1.351 + signature as the class __init__ (as they share the same spec) 1.352 + 1.353 + You create auto-specced mocks by passing `autospec=True` to `patch`. 1.354 + 1.355 + Note that attributes that are None are special cased and mocked without a 1.356 + spec (so any attribute / method can be used). This is because None is 1.357 + typically used as a default value for attributes that may be of some other 1.358 + type, and as we don't know what type that may be we allow all access. 1.359 + 1.360 + Note that the `autospec` option to `patch` obsoletes the `mocksignature` 1.361 + option. 1.362 + 1.363 +* Added the `create_autospec` function for manually creating 'auto-specced' 1.364 + mocks 1.365 +* Removal of deprecated `patch_object` 1.366 + 1.367 + 1.368 +2011/05/30 Version 0.7.2 1.369 +------------------------ 1.370 + 1.371 +* BUGFIX: instances of list subclasses can now be used as mock specs 1.372 +* BUGFIX: MagicMock equality / inequality protocol methods changed to use the 1.373 + default equality / inequality. This is done through a `side_effect` on 1.374 + the mocks used for `__eq__` / `__ne__` 1.375 + 1.376 + 1.377 +2011/05/06 Version 0.7.1 1.378 +------------------------ 1.379 + 1.380 +Package fixes contributed by Michael Fladischer. No code changes. 1.381 + 1.382 +* Include template in package 1.383 +* Use isolated binaries for the tox tests 1.384 +* Unset executable bit on docs 1.385 +* Fix DOS line endings in getting-started.txt 1.386 + 1.387 + 1.388 +2011/03/05 Version 0.7.0 1.389 +------------------------ 1.390 + 1.391 +No API changes since 0.7.0 rc1. Many documentation changes including a stylish 1.392 +new `Sphinx theme <https://github.com/coordt/ADCtheme/>`_. 1.393 + 1.394 +The full set of changes since 0.6.0 are: 1.395 + 1.396 +* Python 3 compatibility 1.397 +* Ability to mock magic methods with `Mock` and addition of `MagicMock` 1.398 + with pre-created magic methods 1.399 +* Addition of `mocksignature` and `mocksignature` argument to `patch` and 1.400 + `patch.object` 1.401 +* Addition of `patch.dict` for changing dictionaries during a test 1.402 +* Ability to use `patch`, `patch.object` and `patch.dict` as class decorators 1.403 +* Renamed ``patch_object`` to `patch.object` (``patch_object`` is 1.404 + deprecated) 1.405 +* Addition of soft comparisons: `call_args`, `call_args_list` and `method_calls` 1.406 + now return tuple-like objects which compare equal even when empty args 1.407 + or kwargs are skipped 1.408 +* patchers (`patch`, `patch.object` and `patch.dict`) have start and stop 1.409 + methods 1.410 +* Addition of `assert_called_once_with` method 1.411 +* Mocks can now be named (`name` argument to constructor) and the name is used 1.412 + in the repr 1.413 +* repr of a mock with a spec includes the class name of the spec 1.414 +* `assert_called_with` works with `python -OO` 1.415 +* New `spec_set` keyword argument to `Mock` and `patch`. If used, 1.416 + attempting to *set* an attribute on a mock not on the spec will raise an 1.417 + `AttributeError` 1.418 +* Mocks created with a spec can now pass `isinstance` tests (`__class__` 1.419 + returns the type of the spec) 1.420 +* Added docstrings to all objects 1.421 +* Improved failure message for `Mock.assert_called_with` when the mock 1.422 + has not been called at all 1.423 +* Decorated functions / methods have their docstring and `__module__` 1.424 + preserved on Python 2.4. 1.425 +* BUGFIX: `mock.patch` now works correctly with certain types of objects that 1.426 + proxy attribute access, like the django settings object 1.427 +* BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and 1.428 + diagnosing this) 1.429 +* BUGFIX: `spec=True` works with old style classes 1.430 +* BUGFIX: ``help(mock)`` works now (on the module). Can no longer use ``__bases__`` 1.431 + as a valid sentinel name (thanks to Stephen Emslie for reporting and 1.432 + diagnosing this) 1.433 +* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like 1.434 + ``KeyboardInterrupt`` 1.435 +* BUGFIX: `reset_mock` caused infinite recursion when a mock is set as its own 1.436 + return value 1.437 +* BUGFIX: patching the same object twice now restores the patches correctly 1.438 +* with statement tests now skipped on Python 2.4 1.439 +* Tests require unittest2 (or unittest2-py3k) to run 1.440 +* Tested with `tox <http://pypi.python.org/pypi/tox>`_ on Python 2.4 - 3.2, 1.441 + jython and pypy (excluding 3.0) 1.442 +* Added 'build_sphinx' command to setup.py (requires setuptools or distribute) 1.443 + Thanks to Florian Bauer 1.444 +* Switched from subversion to mercurial for source code control 1.445 +* `Konrad Delong <http://konryd.blogspot.com/>`_ added as co-maintainer 1.446 + 1.447 + 1.448 +2011/02/16 Version 0.7.0 RC 1 1.449 +----------------------------- 1.450 + 1.451 +Changes since beta 4: 1.452 + 1.453 +* Tested with jython, pypy and Python 3.2 and 3.1 1.454 +* Decorated functions / methods have their docstring and `__module__` 1.455 + preserved on Python 2.4 1.456 +* BUGFIX: `mock.patch` now works correctly with certain types of objects that 1.457 + proxy attribute access, like the django settings object 1.458 +* BUGFIX: `reset_mock` caused infinite recursion when a mock is set as its own 1.459 + return value 1.460 + 1.461 + 1.462 +2010/11/12 Version 0.7.0 beta 4 1.463 +------------------------------- 1.464 + 1.465 +* patchers (`patch`, `patch.object` and `patch.dict`) have start and stop 1.466 + methods 1.467 +* Addition of `assert_called_once_with` method 1.468 +* repr of a mock with a spec includes the class name of the spec 1.469 +* `assert_called_with` works with `python -OO` 1.470 +* New `spec_set` keyword argument to `Mock` and `patch`. If used, 1.471 + attempting to *set* an attribute on a mock not on the spec will raise an 1.472 + `AttributeError` 1.473 +* Attributes and return value of a `MagicMock` are `MagicMock` objects 1.474 +* Attempting to set an unsupported magic method now raises an `AttributeError` 1.475 +* `patch.dict` works as a class decorator 1.476 +* Switched from subversion to mercurial for source code control 1.477 +* BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and 1.478 + diagnosing this) 1.479 +* BUGFIX: `spec=True` works with old style classes 1.480 +* BUGFIX: `mocksignature=True` can now patch instance methods via 1.481 + `patch.object` 1.482 + 1.483 + 1.484 +2010/09/18 Version 0.7.0 beta 3 1.485 +------------------------------- 1.486 + 1.487 +* Using spec with :class:`MagicMock` only pre-creates magic methods in the spec 1.488 +* Setting a magic method on a mock with a ``spec`` can only be done if the 1.489 + spec has that method 1.490 +* Mocks can now be named (`name` argument to constructor) and the name is used 1.491 + in the repr 1.492 +* `mocksignature` can now be used with classes (signature based on `__init__`) 1.493 + and callable objects (signature based on `__call__`) 1.494 +* Mocks created with a spec can now pass `isinstance` tests (`__class__` 1.495 + returns the type of the spec) 1.496 +* Default numeric value for MagicMock is 1 rather than zero (because the 1.497 + MagicMock bool defaults to True and 0 is False) 1.498 +* Improved failure message for :meth:`~Mock.assert_called_with` when the mock 1.499 + has not been called at all 1.500 +* Adding the following to the set of supported magic methods: 1.501 + 1.502 + - ``__getformat__`` and ``__setformat__`` 1.503 + - pickle methods 1.504 + - ``__trunc__``, ``__ceil__`` and ``__floor__`` 1.505 + - ``__sizeof__`` 1.506 + 1.507 +* Added 'build_sphinx' command to setup.py (requires setuptools or distribute) 1.508 + Thanks to Florian Bauer 1.509 +* with statement tests now skipped on Python 2.4 1.510 +* Tests require unittest2 to run on Python 2.7 1.511 +* Improved several docstrings and documentation 1.512 + 1.513 + 1.514 +2010/06/23 Version 0.7.0 beta 2 1.515 +------------------------------- 1.516 + 1.517 +* :func:`patch.dict` works as a context manager as well as a decorator 1.518 +* ``patch.dict`` takes a string to specify dictionary as well as a dictionary 1.519 + object. If a string is supplied the name specified is imported 1.520 +* BUGFIX: ``patch.dict`` restores dictionary even when an exception is raised 1.521 + 1.522 + 1.523 +2010/06/22 Version 0.7.0 beta 1 1.524 +------------------------------- 1.525 + 1.526 +* Addition of :func:`mocksignature` 1.527 +* Ability to mock magic methods 1.528 +* Ability to use ``patch`` and ``patch.object`` as class decorators 1.529 +* Renamed ``patch_object`` to :func:`patch.object` (``patch_object`` is 1.530 + deprecated) 1.531 +* Addition of :class:`MagicMock` class with all magic methods pre-created for you 1.532 +* Python 3 compatibility (tested with 3.2 but should work with 3.0 & 3.1 as 1.533 + well) 1.534 +* Addition of :func:`patch.dict` for changing dictionaries during a test 1.535 +* Addition of ``mocksignature`` argument to ``patch`` and ``patch.object`` 1.536 +* ``help(mock)`` works now (on the module). Can no longer use ``__bases__`` 1.537 + as a valid sentinel name (thanks to Stephen Emslie for reporting and 1.538 + diagnosing this) 1.539 +* Addition of soft comparisons: `call_args`, `call_args_list` and `method_calls` 1.540 + now return tuple-like objects which compare equal even when empty args 1.541 + or kwargs are skipped 1.542 +* Added docstrings. 1.543 +* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like 1.544 + ``KeyboardInterrupt`` 1.545 +* BUGFIX: patching the same object twice now restores the patches correctly 1.546 +* The tests now require `unittest2 <http://pypi.python.org/pypi/unittest2>`_ 1.547 + to run 1.548 +* `Konrad Delong <http://konryd.blogspot.com/>`_ added as co-maintainer 1.549 + 1.550 + 1.551 +2009/08/22 Version 0.6.0 1.552 +------------------------ 1.553 + 1.554 +* New test layout compatible with test discovery 1.555 +* Descriptors (static methods / class methods etc) can now be patched and 1.556 + restored correctly 1.557 +* Mocks can raise exceptions when called by setting ``side_effect`` to an 1.558 + exception class or instance 1.559 +* Mocks that wrap objects will not pass on calls to the underlying object if 1.560 + an explicit return_value is set 1.561 + 1.562 + 1.563 +2009/04/17 Version 0.5.0 1.564 +------------------------ 1.565 + 1.566 +* Made DEFAULT part of the public api. 1.567 +* Documentation built with Sphinx. 1.568 +* ``side_effect`` is now called with the same arguments as the mock is called with and 1.569 + if returns a non-DEFAULT value that is automatically set as the ``mock.return_value``. 1.570 +* ``wraps`` keyword argument used for wrapping objects (and passing calls through to the wrapped object). 1.571 +* ``Mock.reset`` renamed to ``Mock.reset_mock``, as reset is a common API name. 1.572 +* ``patch`` / ``patch_object`` are now context managers and can be used with ``with``. 1.573 +* A new 'create' keyword argument to patch and patch_object that allows them to patch 1.574 + (and unpatch) attributes that don't exist. (Potentially unsafe to use - it can allow 1.575 + you to have tests that pass when they are testing an API that doesn't exist - use at 1.576 + your own risk!) 1.577 +* The methods keyword argument to Mock has been removed and merged with spec. The spec 1.578 + argument can now be a list of methods or an object to take the spec from. 1.579 +* Nested patches may now be applied in a different order (created mocks passed 1.580 + in the opposite order). This is actually a bugfix. 1.581 +* patch and patch_object now take a spec keyword argument. If spec is 1.582 + passed in as 'True' then the Mock created will take the object it is replacing 1.583 + as its spec object. If the object being replaced is a class, then the return 1.584 + value for the mock will also use the class as a spec. 1.585 +* A Mock created without a spec will not attempt to mock any magic methods / attributes 1.586 + (they will raise an ``AttributeError`` instead). 1.587 + 1.588 + 1.589 +2008/10/12 Version 0.4.0 1.590 +------------------------ 1.591 + 1.592 +* Default return value is now a new mock rather than None 1.593 +* return_value added as a keyword argument to the constructor 1.594 +* New method 'assert_called_with' 1.595 +* Added 'side_effect' attribute / keyword argument called when mock is called 1.596 +* patch decorator split into two decorators: 1.597 + 1.598 + - ``patch_object`` which takes an object and an attribute name to patch 1.599 + (plus optionally a value to patch with which defaults to a mock object) 1.600 + - ``patch`` which takes a string specifying a target to patch; in the form 1.601 + 'package.module.Class.attribute'. (plus optionally a value to 1.602 + patch with which defaults to a mock object) 1.603 + 1.604 +* Can now patch objects with ``None`` 1.605 +* Change to patch for nose compatibility with error reporting in wrapped functions 1.606 +* Reset no longer clears children / return value etc - it just resets 1.607 + call count and call args. It also calls reset on all children (and 1.608 + the return value if it is a mock). 1.609 + 1.610 +Thanks to Konrad Delong, Kevin Dangoor and others for patches and suggestions. 1.611 + 1.612 + 1.613 +2007/12/03 Version 0.3.1 1.614 +------------------------- 1.615 + 1.616 +``patch`` maintains the name of decorated functions for compatibility with nose 1.617 +test autodiscovery. 1.618 + 1.619 +Tests decorated with ``patch`` that use the two argument form (implicit mock 1.620 +creation) will receive the mock(s) passed in as extra arguments. 1.621 + 1.622 +Thanks to Kevin Dangoor for these changes. 1.623 + 1.624 + 1.625 +2007/11/30 Version 0.3.0 1.626 +------------------------- 1.627 + 1.628 +Removed ``patch_module``. ``patch`` can now take a string as the first 1.629 +argument for patching modules. 1.630 + 1.631 +The third argument to ``patch`` is optional - a mock will be created by 1.632 +default if it is not passed in. 1.633 + 1.634 + 1.635 +2007/11/21 Version 0.2.1 1.636 +------------------------- 1.637 + 1.638 +Bug fix, allows reuse of functions decorated with ``patch`` and ``patch_module``. 1.639 + 1.640 + 1.641 +2007/11/20 Version 0.2.0 1.642 +------------------------- 1.643 + 1.644 +Added ``spec`` keyword argument for creating ``Mock`` objects from a 1.645 +specification object. 1.646 + 1.647 +Added ``patch`` and ``patch_module`` monkey patching decorators. 1.648 + 1.649 +Added ``sentinel`` for convenient access to unique objects. 1.650 + 1.651 +Distribution includes unit tests. 1.652 + 1.653 + 1.654 +2007/11/19 Version 0.1.0 1.655 +------------------------- 1.656 + 1.657 +Initial release. 1.658 + 1.659 + 1.660 +TODO and Limitations 1.661 +==================== 1.662 + 1.663 +Contributions, bug reports and comments welcomed! 1.664 + 1.665 +Feature requests and bug reports are handled on the issue tracker: 1.666 + 1.667 + * `mock issue tracker <http://code.google.com/p/mock/issues/list>`_ 1.668 + 1.669 +`wraps` is not integrated with magic methods. 1.670 + 1.671 +`patch` could auto-do the patching in the constructor and unpatch in the 1.672 +destructor. This would be useful in itself, but violates TOOWTDI and would be 1.673 +unsafe for IronPython & PyPy (non-deterministic calling of destructors). 1.674 +Destructors aren't called in CPython where there are cycles, but a weak 1.675 +reference with a callback can be used to get round this. 1.676 + 1.677 +`Mock` has several attributes. This makes it unsuitable for mocking objects 1.678 +that use these attribute names. A way round this would be to provide methods 1.679 +that *hide* these attributes when needed. In 0.8 many, but not all, of these 1.680 +attributes are renamed to gain a `_mock` prefix, making it less likely that 1.681 +they will clash. Any outstanding attributes that haven't been modified with 1.682 +the prefix should be changed. 1.683 + 1.684 +If a patch is started using `patch.start` and then not stopped correctly then 1.685 +the unpatching is not done. Using weak references it would be possible to 1.686 +detect and fix this when the patch object itself is garbage collected. This 1.687 +would be tricky to get right though. 1.688 + 1.689 +When a `Mock` is created by `patch`, arbitrary keywords can be used to set 1.690 +attributes. If `patch` is created with a `spec`, and is replacing a class, then 1.691 +a `return_value` mock is created. The keyword arguments are not applied to the 1.692 +child mock, but could be. 1.693 + 1.694 +When mocking a class with `patch`, passing in `spec=True` or `autospec=True`, 1.695 +the mock class has an instance created from the same spec. Should this be the 1.696 +default behaviour for mocks anyway (mock return values inheriting the spec 1.697 +from their parent), or should it be controlled by an additional keyword 1.698 +argument (`inherit`) to the Mock constructor? `create_autospec` does this, so 1.699 +an additional keyword argument to Mock is probably unnecessary. 1.700 + 1.701 +The `mocksignature` argument to `patch` with a non `Mock` passed into 1.702 +`new_callable` will *probably* cause an error. Should it just be invalid? 1.703 + 1.704 +Note that `NonCallableMock` and `NonCallableMagicMock` still have the unused 1.705 +(and unusable) attributes: `return_value`, `side_effect`, `call_count`, 1.706 +`call_args` and `call_args_list`. These could be removed or raise errors on 1.707 +getting / setting. They also have the `assert_called_with` and 1.708 +`assert_called_once_with` methods. Removing these would be pointless as 1.709 +fetching them would create a mock (attribute) that could be called without 1.710 +error. 1.711 + 1.712 +Some outstanding technical debt. The way autospeccing mocks function 1.713 +signatures was copied and modified from `mocksignature`. This could all be 1.714 +refactored into one set of functions instead of two. The way we tell if 1.715 +patchers are started and if a patcher is being used for a `patch.multiple` 1.716 +call are both horrible. There are now a host of helper functions that should 1.717 +be rationalised. (Probably time to split mock into a package instead of a 1.718 +module.) 1.719 + 1.720 +Passing arbitrary keyword arguments to `create_autospec`, or `patch` with 1.721 +`autospec`, when mocking a *function* works fine. However, the arbitrary 1.722 +attributes are set on the created mock - but `create_autospec` returns a 1.723 +real function (which doesn't have those attributes). However, what is the use 1.724 +case for using autospec to create functions with attributes that don't exist 1.725 +on the original? 1.726 + 1.727 +`mocksignature`, plus the `call_args_list` and `method_calls` attributes of 1.728 +`Mock` could all be deprecated.