summaryrefslogtreecommitdiff
path: root/docs/changelog.txt
blob: 1d8d30c541b40840a5c203382f1be2663378a5f0 (plain)
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
.. currentmodule:: mock


CHANGELOG
=========

2012/XX/XX Version 1.0.0 alpha 3
--------------------------------

* Added `patch.stopall` method to stop all active patches created by `start`
* BUGFIX: calling `MagicMock.reset_mock` wouldn't reset magic method mocks
* BUGFIX: calling `reset_mock` on a `MagicMock` created with autospec could
  raise an exception


2012/05/04 Version 1.0.0 alpha 2
--------------------------------

* `PropertyMock` attributes are now standard `MagicMocks`
* `create_autospec` works with attributes present in results of `dir` that
  can't be fetched from the object's class. Contributed by Konstantine Rybnikov
* Any exceptions in an iterable `side_effect` will be raised instead of
  returned
* In Python 3, `create_autospec` now supports keyword only arguments


2012/03/25 Version 1.0.0 alpha 1
--------------------------------

The standard library version!

* `mocksignature`, along with the `mocksignature` argument to `patch`, removed
* Support for deleting attributes (accessing deleted attributes will raise an
  `AttributeError`)
* Added the `mock_open` helper function for mocking the builtin `open`
* `__class__` is assignable, so a mock can pass an `isinstance` check without
  requiring a spec
* Addition of `PropertyMock`, for mocking properties
* `MagicMocks` made unorderable by default (in Python 3). The comparison
  methods (other than equality and inequality) now return `NotImplemented`
* Propagate traceback info to support subclassing of `_patch` by other
  libraries
* BUGFIX: passing multiple spec arguments to patchers (`spec` , `spec_set` and
  `autospec`) had unpredictable results, now it is an error
* BUGFIX: using `spec=True` *and* `create=True` as arguments to patchers could
  result in using `DEFAULT` as the spec. Now it is an error instead
* BUGFIX: using `spec` or `autospec` arguments to patchers, along with
  `spec_set=True` did not work correctly
* BUGFIX: using an object that evaluates to False as a spec could be ignored
* BUGFIX: a list as the `spec` argument to a patcher would always result in a
  non-callable mock. Now if `__call__` is in the spec the mock is callable


2012/02/13 Version 0.8.0
------------------------

The only changes since 0.8rc2 are:

* Improved repr of :data:`sentinel` objects
* :data:`ANY` can be used for comparisons against :data:`call` objects
* The return value of `MagicMock.__iter__` method can be set to
  any iterable and isn't required to be an iterator

Full List of changes since 0.7:

mock 0.8.0 is the last version that will support Python 2.4.

* Addition of :attr:`~Mock.mock_calls` list for *all* calls (including magic
  methods and chained calls)
* :func:`patch` and :func:`patch.object` now create a :class:`MagicMock`
  instead of a :class:`Mock` by default
* The patchers (`patch`, `patch.object` and `patch.dict`), plus `Mock` and
  `MagicMock`, take arbitrary keyword arguments for configuration
* New mock method :meth:`~Mock.configure_mock` for setting attributes and
  return values / side effects on the mock and its attributes
* New mock assert methods :meth:`~Mock.assert_any_call` and
  :meth:`~Mock.assert_has_calls`
* Implemented :ref:`auto-speccing` (recursive, lazy speccing of mocks with
  mocked signatures for functions/methods), as the `autospec` argument to
  `patch`
* Added the :func:`create_autospec` function for manually creating
  'auto-specced' mocks
* :func:`patch.multiple` for doing multiple patches in a single call, using
  keyword arguments
* Setting :attr:`~Mock.side_effect` to an iterable will cause calls to the mock
  to return the next value from the iterable
* New `new_callable` argument to `patch` and `patch.object` allowing you to
  pass in a class or callable object (instead of `MagicMock`) that will be
  called to replace the object being patched
* Addition of :class:`NonCallableMock` and :class:`NonCallableMagicMock`, mocks
  without a `__call__` method
* Addition of :meth:`~Mock.mock_add_spec` method for adding (or changing) a
  spec on an existing mock
* Protocol methods on :class:`MagicMock` are magic mocks, and are created
  lazily on first lookup. This means the result of calling a protocol method is
  a `MagicMock` instead of a `Mock` as it was previously
* Addition of :meth:`~Mock.attach_mock` method
* Added :data:`ANY` for ignoring arguments in :meth:`~Mock.assert_called_with`
  calls
* Addition of :data:`call` helper object
* Improved repr for mocks
* Improved repr for :attr:`Mock.call_args` and entries in
  :attr:`Mock.call_args_list`, :attr:`Mock.method_calls` and
  :attr:`Mock.mock_calls`
* Improved repr for :data:`sentinel` objects
* `patch` lookup is done at use time not at decoration time
* In Python 2.6 or more recent, `dir` on a mock will report all the dynamically
  created attributes (or the full list of attributes if there is a spec) as
  well as all the mock methods and attributes.
* Module level :data:`FILTER_DIR` added to control whether `dir(mock)` filters
  private attributes. `True` by default.
* `patch.TEST_PREFIX` for controlling how patchers recognise test methods when
  used to decorate a class
* Support for using Java exceptions as a :attr:`~Mock.side_effect` on Jython
* `Mock` call lists (`call_args_list`, `method_calls` & `mock_calls`) are now
  custom list objects that allow membership tests for "sub lists" and have
  a nicer representation if you `str` or `print` them
* Mocks attached as attributes or return values to other mocks have calls
  recorded in `method_calls` and `mock_calls` of the parent (unless a name is
  already set on the child)
* Improved failure messages for `assert_called_with` and
  `assert_called_once_with`
* The return value of the :class:`MagicMock` `__iter__` method can be set to
  any iterable and isn't required to be an iterator
* Added the Mock API (`assert_called_with` etc) to functions created by
  :func:`mocksignature`
* Tuples as well as lists can be used to specify allowed methods for `spec` &
  `spec_set` arguments
* Calling `stop` on an unstarted patcher fails with  a more meaningful error
  message
* Renamed the internal classes `Sentinel` and `SentinelObject` to prevent abuse
* BUGFIX: an error creating a patch, with nested patch decorators, won't leave
  patches in place
* BUGFIX: `__truediv__` and `__rtruediv__` not available as magic methods on
  mocks in Python 3
* BUGFIX: `assert_called_with` / `assert_called_once_with` can be used with
  `self` as a keyword argument
* BUGFIX: when patching a class with an explicit spec / spec_set (not a
  boolean) it applies "spec inheritance" to the return value of the created
  mock (the "instance")
* BUGFIX: remove the `__unittest` marker causing traceback truncation
* Removal of deprecated `patch_object`
* Private attributes `_name`, `_methods`, '_children', `_wraps` and `_parent`
  (etc) renamed to reduce likelihood of clash with user attributes.
* Added license file to the distribution


2012/01/10 Version 0.8.0 release candidate 2
--------------------------------------------

* Removed the `configure` keyword argument to `create_autospec` and allow
  arbitrary keyword arguments (for the `Mock` constructor) instead
* Fixed `ANY` equality with some types in `assert_called_with` calls
* Switched to a standard Sphinx theme (compatible with
  `readthedocs.org <http://mock.readthedocs.org>`_)


2011/12/29 Version 0.8.0 release candidate 1
--------------------------------------------

* `create_autospec` on the return value of a mocked class will use `__call__`
  for the signature rather than `__init__`
* Performance improvement instantiating `Mock` and `MagicMock`
* Mocks used as magic methods have the same type as their parent instead of
  being hardcoded to `MagicMock`

Special thanks to Julian Berman for his help with diagnosing and improving
performance in this release.


2011/10/09 Version 0.8.0 beta 4
-------------------------------

* `patch` lookup is done at use time not at decoration time
* When attaching a Mock to another Mock as a magic method, calls are recorded
  in mock_calls
* Addition of `attach_mock` method
* Renamed the internal classes `Sentinel` and `SentinelObject` to prevent abuse
* BUGFIX: various issues around circular references with mocks (setting a mock
  return value to be itself etc)


2011/08/15 Version 0.8.0 beta 3
-------------------------------

* Mocks attached as attributes or return values to other mocks have calls
  recorded in `method_calls` and `mock_calls` of the parent (unless a name is
  already set on the child)
* Addition of `mock_add_spec` method for adding (or changing) a spec on an
  existing mock
* Improved repr for `Mock.call_args` and entries in `Mock.call_args_list`,
  `Mock.method_calls` and `Mock.mock_calls`
* Improved repr for mocks
* BUGFIX: minor fixes in the way `mock_calls` is worked out,
  especially for "intermediate" mocks in a call chain


2011/08/05 Version 0.8.0 beta 2
-------------------------------

* Setting `side_effect` to an iterable will cause calls to the mock to return
  the next value from the iterable
* Added `assert_any_call` method
* Moved `assert_has_calls` from call lists onto mocks
* BUGFIX: `call_args` and all members of `call_args_list` are two tuples of
  `(args, kwargs)` again instead of three tuples of `(name, args, kwargs)`


2011/07/25 Version 0.8.0 beta 1
-------------------------------

* `patch.TEST_PREFIX` for controlling how patchers recognise test methods when
  used to decorate a class
* `Mock` call lists (`call_args_list`, `method_calls` & `mock_calls`) are now
  custom list objects that allow membership tests for "sub lists" and have
  an `assert_has_calls` method for unordered call checks
* `callargs` changed to *always* be a three-tuple of `(name, args, kwargs)`
* Addition of `mock_calls` list for *all* calls (including magic methods and
  chained calls)
* Extension of `call` object to support chained calls and `callargs` for better
  comparisons with or without names. `call` object has a `call_list` method for
  chained calls
* Added the public `instance` argument to `create_autospec`
* Support for using Java exceptions as a `side_effect` on Jython
* Improved failure messages for `assert_called_with` and
  `assert_called_once_with`
* Tuples as well as lists can be used to specify allowed methods for `spec` &
  `spec_set` arguments
* BUGFIX: Fixed bug in `patch.multiple` for argument passing when creating
  mocks
* Added license file to the distribution


2011/07/16 Version 0.8.0 alpha 2
--------------------------------

* `patch.multiple` for doing multiple patches in a single call, using keyword
  arguments
* New `new_callable` argument to `patch` and `patch.object` allowing you to
  pass in a class or callable object (instead of `MagicMock`) that will be
  called to replace the object being patched
* Addition of `NonCallableMock` and `NonCallableMagicMock`, mocks without a
  `__call__` method
* Mocks created by `patch` have a `MagicMock` as the `return_value` where a
  class is being patched
* `create_autospec` can create non-callable mocks for non-callable objects.
  `return_value` mocks of classes will be non-callable unless the class has
  a `__call__` method
* `autospec` creates a `MagicMock` without a spec for properties and slot
  descriptors, because we don't know the type of object they return
* Removed the "inherit" argument from `create_autospec`
* Calling `stop` on an unstarted patcher fails with  a more meaningful error
  message
* BUGFIX: an error creating a patch, with nested patch decorators, won't leave
  patches in place
* BUGFIX: `__truediv__` and `__rtruediv__` not available as magic methods on
  mocks in Python 3
* BUGFIX: `assert_called_with` / `assert_called_once_with` can be used with
  `self` as a keyword argument
* BUGFIX: autospec for functions / methods with an argument named self that
  isn't the first argument no longer broken
* BUGFIX: when patching a class with an explicit spec / spec_set (not a
  boolean) it applies "spec inheritance" to the return value of the created
  mock (the "instance")
* BUGFIX: remove the `__unittest` marker causing traceback truncation


2011/06/14 Version 0.8.0 alpha 1
--------------------------------

mock 0.8.0 is the last version that will support Python 2.4.

* The patchers (`patch`, `patch.object` and `patch.dict`), plus `Mock` and
  `MagicMock`, take arbitrary keyword arguments for configuration
* New mock method `configure_mock` for setting attributes and return values /
  side effects on the mock and its attributes
* In Python 2.6 or more recent, `dir` on a mock will report all the dynamically
  created attributes (or the full list of attributes if there is a spec) as
  well as all the mock methods and attributes.
* Module level `FILTER_DIR` added to control whether `dir(mock)` filters
  private attributes. `True` by default. Note that `vars(Mock())` can still be
  used to get all instance attributes and `dir(type(Mock())` will still return
  all the other attributes (irrespective of `FILTER_DIR`)
* `patch` and `patch.object` now create a `MagicMock` instead of a `Mock` by
  default
* Added `ANY` for ignoring arguments in `assert_called_with` calls
* Addition of `call` helper object
* Protocol methods on `MagicMock` are magic mocks, and are created lazily on
  first lookup. This means the result of calling a protocol method is a
  MagicMock instead of a Mock as it was previously
* Added the Mock API (`assert_called_with` etc) to functions created by
  `mocksignature`
* Private attributes `_name`, `_methods`, '_children', `_wraps` and `_parent`
  (etc) renamed to reduce likelihood of clash with user attributes.
* Implemented auto-speccing (recursive, lazy speccing of mocks with mocked
  signatures for functions/methods)

  Limitations:

  - Doesn't mock magic methods or attributes (it creates MagicMocks, so the
    magic methods are *there*, they just don't have the signature mocked nor
    are attributes followed)
  - Doesn't mock function / method attributes
  - Uses object traversal on the objects being mocked to determine types - so
    properties etc may be triggered
  - The return value of mocked classes (the 'instance') has the same call
    signature as the class __init__ (as they share the same spec)

  You create auto-specced mocks by passing `autospec=True` to `patch`.

  Note that attributes that are None are special cased and mocked without a
  spec (so any attribute / method can be used). This is because None is
  typically used as a default value for attributes that may be of some other
  type, and as we don't know what type that may be we allow all access.

  Note that the `autospec` option to `patch` obsoletes the `mocksignature`
  option.

* Added the `create_autospec` function for manually creating 'auto-specced'
  mocks
* Removal of deprecated `patch_object`


2011/05/30 Version 0.7.2
------------------------

* BUGFIX: instances of list subclasses can now be used as mock specs
* BUGFIX: MagicMock equality / inequality protocol methods changed to use the
  default equality / inequality. This is done through a `side_effect` on
  the mocks used for `__eq__` / `__ne__`


2011/05/06 Version 0.7.1
------------------------

Package fixes contributed by Michael Fladischer. No code changes.

* Include template in package
* Use isolated binaries for the tox tests
* Unset executable bit on docs
* Fix DOS line endings in getting-started.txt


2011/03/05 Version 0.7.0
------------------------

No API changes since 0.7.0 rc1. Many documentation changes including a stylish
new `Sphinx theme <https://github.com/coordt/ADCtheme/>`_.

The full set of changes since 0.6.0 are:

* Python 3 compatibility
* Ability to mock magic methods with `Mock` and addition of `MagicMock`
  with pre-created magic methods
* Addition of `mocksignature` and `mocksignature` argument to `patch` and
  `patch.object`
* Addition of `patch.dict` for changing dictionaries during a test
* Ability to use `patch`, `patch.object` and `patch.dict` as class decorators
* Renamed ``patch_object`` to `patch.object` (``patch_object`` is
  deprecated)
* Addition of soft comparisons: `call_args`, `call_args_list` and `method_calls`
  now return tuple-like objects which compare equal even when empty args
  or kwargs are skipped
* patchers (`patch`, `patch.object` and `patch.dict`) have start and stop
  methods
* Addition of `assert_called_once_with` method
* Mocks can now be named (`name` argument to constructor) and the name is used
  in the repr
* repr of a mock with a spec includes the class name of the spec
* `assert_called_with` works with `python -OO`
* New `spec_set` keyword argument to `Mock` and `patch`. If used,
  attempting to *set* an attribute on a mock not on the spec will raise an
  `AttributeError`
* Mocks created with a spec can now pass `isinstance` tests (`__class__`
  returns the type of the spec)
* Added docstrings to all objects
* Improved failure message for `Mock.assert_called_with` when the mock
  has not been called at all
* Decorated functions / methods have their docstring and `__module__`
  preserved on Python 2.4.
* BUGFIX: `mock.patch` now works correctly with certain types of objects that
  proxy attribute access, like the django settings object
* BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and
  diagnosing this)
* BUGFIX: `spec=True` works with old style classes
* BUGFIX: ``help(mock)`` works now (on the module). Can no longer use ``__bases__``
  as a valid sentinel name (thanks to Stephen Emslie for reporting and
  diagnosing this)
* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like
  ``KeyboardInterrupt``
* BUGFIX: `reset_mock` caused infinite recursion when a mock is set as its own
  return value
* BUGFIX: patching the same object twice now restores the patches correctly
* with statement tests now skipped on Python 2.4
* Tests require unittest2 (or unittest2-py3k) to run
* Tested with `tox <http://pypi.python.org/pypi/tox>`_ on Python 2.4 - 3.2,
  jython and pypy (excluding 3.0)
* Added 'build_sphinx' command to setup.py (requires setuptools or distribute)
  Thanks to Florian Bauer
* Switched from subversion to mercurial for source code control
* `Konrad Delong <http://konryd.blogspot.com/>`_ added as co-maintainer


2011/02/16 Version 0.7.0 RC 1
-----------------------------

Changes since beta 4:

* Tested with jython, pypy and Python 3.2 and 3.1
* Decorated functions / methods have their docstring and `__module__`
  preserved on Python 2.4
* BUGFIX: `mock.patch` now works correctly with certain types of objects that
  proxy attribute access, like the django settings object
* BUGFIX: `reset_mock` caused infinite recursion when a mock is set as its own
  return value


2010/11/12 Version 0.7.0 beta 4
-------------------------------

* patchers (`patch`, `patch.object` and `patch.dict`) have start and stop
  methods
* Addition of `assert_called_once_with` method
* repr of a mock with a spec includes the class name of the spec
* `assert_called_with` works with `python -OO`
* New `spec_set` keyword argument to `Mock` and `patch`. If used,
  attempting to *set* an attribute on a mock not on the spec will raise an
  `AttributeError`
* Attributes and return value of a `MagicMock` are `MagicMock` objects
* Attempting to set an unsupported magic method now raises an `AttributeError`
* `patch.dict` works as a class decorator
* Switched from subversion to mercurial for source code control
* BUGFIX: mocks are now copyable (thanks to Ned Batchelder for reporting and
  diagnosing this)
* BUGFIX: `spec=True` works with old style classes
* BUGFIX: `mocksignature=True` can now patch instance methods via
  `patch.object`


2010/09/18 Version 0.7.0 beta 3
-------------------------------

* Using spec with :class:`MagicMock` only pre-creates magic methods in the spec
* Setting a magic method on a mock with a ``spec`` can only be done if the
  spec has that method
* Mocks can now be named (`name` argument to constructor) and the name is used
  in the repr
* `mocksignature` can now be used with classes (signature based on `__init__`)
  and callable objects (signature based on `__call__`)
* Mocks created with a spec can now pass `isinstance` tests (`__class__`
  returns the type of the spec)
* Default numeric value for MagicMock is 1 rather than zero (because the
  MagicMock bool defaults to True and 0 is False)
* Improved failure message for :meth:`~Mock.assert_called_with` when the mock
  has not been called at all
* Adding the following to the set of supported magic methods:

  - ``__getformat__`` and ``__setformat__``
  - pickle methods
  - ``__trunc__``, ``__ceil__`` and ``__floor__``
  - ``__sizeof__``

* Added 'build_sphinx' command to setup.py (requires setuptools or distribute)
  Thanks to Florian Bauer
* with statement tests now skipped on Python 2.4
* Tests require unittest2 to run on Python 2.7
* Improved several docstrings and documentation


2010/06/23 Version 0.7.0 beta 2
-------------------------------

* :func:`patch.dict` works as a context manager as well as a decorator
* ``patch.dict`` takes a string to specify dictionary as well as a dictionary
  object. If a string is supplied the name specified is imported
* BUGFIX: ``patch.dict`` restores dictionary even when an exception is raised


2010/06/22 Version 0.7.0 beta 1
-------------------------------

* Addition of :func:`mocksignature`
* Ability to mock magic methods
* Ability to use ``patch`` and ``patch.object`` as class decorators
* Renamed ``patch_object`` to :func:`patch.object` (``patch_object`` is
  deprecated)
* Addition of :class:`MagicMock` class with all magic methods pre-created for you
* Python 3 compatibility (tested with 3.2 but should work with 3.0 & 3.1 as
  well)
* Addition of :func:`patch.dict` for changing dictionaries during a test
* Addition of ``mocksignature`` argument to ``patch`` and ``patch.object``
* ``help(mock)`` works now (on the module). Can no longer use ``__bases__``
  as a valid sentinel name (thanks to Stephen Emslie for reporting and
  diagnosing this)
* Addition of soft comparisons: `call_args`, `call_args_list` and `method_calls`
  now return tuple-like objects which compare equal even when empty args
  or kwargs are skipped
* Added docstrings.
* BUGFIX: ``side_effect`` now works with ``BaseException`` exceptions like
  ``KeyboardInterrupt``
* BUGFIX: patching the same object twice now restores the patches correctly
* The tests now require `unittest2 <http://pypi.python.org/pypi/unittest2>`_
  to run
* `Konrad Delong <http://konryd.blogspot.com/>`_ added as co-maintainer


2009/08/22 Version 0.6.0
------------------------

* New test layout compatible with test discovery
* Descriptors (static methods / class methods etc) can now be patched and
  restored correctly
* Mocks can raise exceptions when called by setting ``side_effect`` to an
  exception class or instance
* Mocks that wrap objects will not pass on calls to the underlying object if
  an explicit return_value is set


2009/04/17 Version 0.5.0
------------------------

* Made DEFAULT part of the public api.
* Documentation built with Sphinx.
* ``side_effect`` is now called with the same arguments as the mock is called with and
  if returns a non-DEFAULT value that is automatically set as the ``mock.return_value``.
* ``wraps`` keyword argument used for wrapping objects (and passing calls through to the wrapped object).
* ``Mock.reset`` renamed to ``Mock.reset_mock``, as reset is a common API name.
* ``patch`` / ``patch_object`` are now context managers and can be used with ``with``.
* A new 'create' keyword argument to patch and patch_object that allows them to patch
  (and unpatch) attributes that don't exist. (Potentially unsafe to use - it can allow
  you to have tests that pass when they are testing an API that doesn't exist - use at
  your own risk!)
* The methods keyword argument to Mock has been removed and merged with spec. The spec
  argument can now be a list of methods or an object to take the spec from.
* Nested patches may now be applied in a different order (created mocks passed
  in the opposite order). This is actually a bugfix.
* patch and patch_object now take a spec keyword argument. If spec is
  passed in as 'True' then the Mock created will take the object it is replacing
  as its spec object. If the object being replaced is a class, then the return
  value for the mock will also use the class as a spec.
* A Mock created without a spec will not attempt to mock any magic methods / attributes
  (they will raise an ``AttributeError`` instead).


2008/10/12 Version 0.4.0
------------------------

* Default return value is now a new mock rather than None
* return_value added as a keyword argument to the constructor
* New method 'assert_called_with'
* Added 'side_effect' attribute / keyword argument called when mock is called
* patch decorator split into two decorators:

    - ``patch_object`` which takes an object and an attribute name to patch
      (plus optionally a value to patch with which defaults to a mock object)
    - ``patch`` which takes a string specifying a target to patch; in the form
      'package.module.Class.attribute'. (plus optionally a value to
      patch with which defaults to a mock object)

* Can now patch objects with ``None``
* Change to patch for nose compatibility with error reporting in wrapped functions
* Reset no longer clears children / return value etc - it just resets
  call count and call args. It also calls reset on all children (and
  the return value if it is a mock).

Thanks to Konrad Delong, Kevin Dangoor and others for patches and suggestions.


2007/12/03  Version 0.3.1
-------------------------

``patch`` maintains the name of decorated functions for compatibility with nose
test autodiscovery.

Tests decorated with ``patch`` that use the two argument form (implicit mock
creation) will receive the mock(s) passed in as extra arguments.

Thanks to Kevin Dangoor for these changes.


2007/11/30  Version 0.3.0
-------------------------

Removed ``patch_module``. ``patch`` can now take a string as the first
argument for patching modules.

The third argument to ``patch`` is optional - a mock will be created by
default if it is not passed in.


2007/11/21  Version 0.2.1
-------------------------

Bug fix, allows reuse of functions decorated with ``patch`` and ``patch_module``.


2007/11/20  Version 0.2.0
-------------------------

Added ``spec`` keyword argument for creating ``Mock`` objects from a
specification object.

Added ``patch`` and ``patch_module`` monkey patching decorators.

Added ``sentinel`` for convenient access to unique objects.

Distribution includes unit tests.


2007/11/19  Version 0.1.0
-------------------------

Initial release.


TODO and Limitations
====================

Contributions, bug reports and comments welcomed!

Feature requests and bug reports are handled on the issue tracker:

 * `mock issue tracker <http://code.google.com/p/mock/issues/list>`_

`wraps` is not integrated with magic methods.

`patch` could auto-do the patching in the constructor and unpatch in the
destructor. This would be useful in itself, but violates TOOWTDI and would be
unsafe for IronPython & PyPy (non-deterministic calling of destructors).
Destructors aren't called in CPython where there are cycles, but a weak
reference with a callback can be used to get round this.

`Mock` has several attributes. This makes it unsuitable for mocking objects
that use these attribute names. A way round this would be to provide methods
that *hide* these attributes when needed. In 0.8 many, but not all, of these
attributes are renamed to gain a `_mock` prefix, making it less likely that
they will clash. Any outstanding attributes that haven't been modified with
the prefix should be changed.

If a patch is started using `patch.start` and then not stopped correctly then
the unpatching is not done. Using weak references it would be possible to
detect and fix this when the patch object itself is garbage collected. This
would be tricky to get right though.

When a `Mock` is created by `patch`, arbitrary keywords can be used to set
attributes. If `patch` is created with a `spec`, and is replacing a class, then
a `return_value` mock is created. The keyword arguments are not applied to the
child mock, but could be.

When mocking a class with `patch`, passing in `spec=True` or `autospec=True`,
the mock class has an instance created from the same spec. Should this be the
default behaviour for mocks anyway (mock return values inheriting the spec
from their parent), or should it be controlled by an additional keyword
argument (`inherit`) to the Mock constructor? `create_autospec` does this, so
an additional keyword argument to Mock is probably unnecessary.

The `mocksignature` argument to `patch` with a non `Mock` passed into
`new_callable` will *probably* cause an error. Should it just be invalid?

Note that `NonCallableMock` and `NonCallableMagicMock` still have the unused
(and unusable) attributes: `return_value`, `side_effect`, `call_count`,
`call_args` and `call_args_list`. These could be removed or raise errors on
getting / setting. They also have the `assert_called_with` and
`assert_called_once_with` methods. Removing these would be pointless as
fetching them would create a mock (attribute) that could be called without
error.

Some outstanding technical debt. The way autospeccing mocks function
signatures was copied and modified from `mocksignature`. This could all be
refactored into one set of functions instead of two. The way we tell if
patchers are started and if a patcher is being used for a `patch.multiple`
call are both horrible. There are now a host of helper functions that should
be rationalised. (Probably time to split mock into a package instead of a
module.)

Passing arbitrary keyword arguments to `create_autospec`, or `patch` with
`autospec`, when mocking a *function* works fine. However, the arbitrary
attributes are set on the created mock - but `create_autospec` returns a
real function (which doesn't have those attributes). However, what is the use
case for using autospec to create functions with attributes that don't exist
on the original?

`mocksignature`, plus the `call_args_list` and `method_calls` attributes of
`Mock` could all be deprecated.