Tony Flury
2087023fde
bpo-32933: Implement __iter__ method on mock_open() (GH-5974)
2018-09-13 01:21:16 +03:00
davidair
2b32da2fea
Improve error message when mock.assert_has_calls fails (GH-8205)
...
This makes the assertion error message more useful, aiding debugging.
Thanks @davidair!
2018-08-17 12:09:58 -07:00
Ned Deily
9d6d06e806
pypi.python.org -> pypi.org (GH-7613)
2018-06-11 00:45:50 -04:00
John Reese
6c4fab0f4b
bpo-33516: Add support for __round__ in MagicMock (GH-6880)
...
unittest.mock.MagicMock now supports the __round__() magic method.
2018-05-22 22:01:10 +02:00
Mario Corchero
552be9d7e6
bpo-30541: Add new method to seal mocks (GH61923)
...
The new method allows the developer to control when to stop the
feature of mocks that automagically creates new mocks when accessing
an attribute that was not declared before
Signed-off-by: Mario Corchero <mariocj89@gmail.com>
2017-10-17 04:35:11 -07:00
Aaron Gallagher
856cbcc12f
bpo-29403: Fix mock's broken autospec behavior on method-bound builtin functions (GH-3)
...
Cython will, in the right circumstances, offer a MethodType instance
where im_func is a builtin function. Any instance of MethodType is
automatically assumed to be a Python-defined function (more
specifically, a function that has an inspectable signature), but
_set_signature was still conservative in its assumptions. As a result
_set_signature would return early with None instead of a mock since
the im_func had no inspectable signature. This causes problems
deeper inside mock, as _set_signature is assumed to _always_
return a mock, and nothing checked its return value.
In similar corner cases, autospec will simply not check the spec of the
function, so _set_signature is amended to now return early with the
original, not-wrapped mock object.
Patch by Aaron Gallagher.
2017-07-20 03:01:14 +03:00
Arne de Laat
324c5d8ca6
bpo-28911: Clarify the behaviour of assert_called_once_with. ( #251 )
2017-02-23 15:57:25 +01:00
Serhiy Storchaka
19dea2c726
Issue #28735 : Fixed the comparison of mock.MagickMock with mock.ANY.
2017-01-21 23:17:25 +02:00
Serhiy Storchaka
a203360836
Issue #28735 : Fixed the comparison of mock.MagickMock with mock.ANY.
2017-01-21 23:15:18 +02:00
Serhiy Storchaka
362f058a89
Issue #28735 : Fixed the comparison of mock.MagickMock with mock.ANY.
2017-01-21 23:12:58 +02:00
Serhiy Storchaka
d9c956fb23
Issue #20804 : The unittest.mock.sentinel attributes now preserve their
...
identity when they are copied or pickled.
2017-01-11 20:13:03 +02:00
Victor Stinner
cd992bbe73
Merge 3.6
2017-01-06 18:16:07 +01:00
Victor Stinner
84b6fb0eea
Fix unittest.mock._Call: don't ignore name
...
Issue #28961 : Fix unittest.mock._Call helper: don't ignore the name parameter
anymore.
Patch written by Jiajun Huang.
2017-01-06 18:15:51 +01:00
Berker Peksag
161a4dd495
Issue #28919 : Simplify _copy_func_details() in unittest.mock
...
Patch by Jiajun Huang.
2016-12-15 05:21:44 +03:00
Gregory P. Smith
ac5084b6c7
Fixes issue28380: unittest.mock Mock autospec functions now properly support
...
assert_called, assert_not_called, and assert_called_once.
2016-10-06 14:31:23 -07:00
Gregory P. Smith
c35a32fe85
Issue #26750 : use inspect.isdatadescriptor instead of our own
...
_is_data_descriptor().
2016-08-15 23:56:32 -07:00
Gregory P. Smith
d4583d7fea
Issue #26750 : use inspect.isdatadescriptor instead of our own
...
_is_data_descriptor().
2016-08-15 23:23:40 -07:00
Gregory P. Smith
d0d24fd1ae
Issue #26750 : unittest.mock.create_autospec() now works properly for
...
subclasses of property() and other data descriptors. Removes the never
publicly used, never documented unittest.mock.DescriptorTypes tuple.
2016-08-07 09:06:27 -07:00
Gregory P. Smith
9854789efe
Issue #26750 : unittest.mock.create_autospec() now works properly
...
for subclasses of property() and other data descriptors.
2016-08-07 08:52:26 -07:00
Martin Panter
702f4f5d6f
Issue #23804 : Merge spelling and NEWS fixes from 3.5
2016-07-11 12:54:44 +00:00
Martin Panter
204bf0b9ae
English spelling and grammar fixes
2016-07-11 07:51:37 +00:00
Serhiy Storchaka
6c85091b5b
Issue #23641 : Added __getnewargs_ex__ to the list of special mock attributes.
2016-06-19 18:32:07 +03:00
Serhiy Storchaka
5943ea76d5
Issue #23641 : Added __getnewargs_ex__ to the list of special mock attributes.
2016-06-19 18:30:43 +03:00
Kushal Das
9cd39a170b
Issue #21271 : Adds new keyword only parameters in reset_mock call
...
We now have two keyword only parameters in the reset_mock function to
selectively reset the return_value or the side_effects, or both.
2016-06-02 10:20:16 -07:00
Robert Collins
c85dd85f1a
Issue #26807 : mock_open 'files' no longer error on readline at end of file.
...
Patch from Yolanda Robla.
2016-05-16 15:22:45 +12:00
Robert Collins
9549a3e3d4
Issue #26807 : mock_open 'files' no longer error on readline at end of file.
...
Patch from Yolanda Robla.
2016-05-16 15:22:01 +12:00
Berker Peksag
5a6c018b57
Issue #25195 : Fix a regression in mock.MagicMock
...
_Call is a subclass of tuple (changeset 3603bae63c13 only works
for classes) so we need to implement __ne__ ourselves.
Patch by Andrew Plummer.
2016-03-28 00:30:40 +03:00
Berker Peksag
ce913877e4
Issue #25195 : Fix a regression in mock.MagicMock
...
_Call is a subclass of tuple (changeset 3603bae63c13 only works
for classes) so we need to implement __ne__ ourselves.
Patch by Andrew Plummer.
2016-03-28 00:30:02 +03:00
Victor Stinner
2c2a4e63d7
Add Mock.assert_called()
...
Issue #26323 : Add assert_called() and assert_called_once() methods to
unittest.mock.Mock.
2016-03-11 22:17:48 +01:00
Senthil Kumaran
121edbf7e2
Issue25347 - Format the error message output of mock's assert_has_calls method.
...
Patch contributed by Robert Zimmerman.
2016-01-12 06:18:32 -08:00
Senthil Kumaran
81bc927da7
Issue #22138 : Fix mock.patch behavior when patching descriptors. Restore
...
original values after patching.
Patch contributed by Sean McCully.
2016-01-08 23:43:29 -08:00
Berker Peksag
29bf4d403d
Issue #24857 : Comparing call_args to a long sequence now correctly returns a
...
boolean result instead of raising an exception.
Patch by A Kaptur.
2015-09-09 23:39:45 +03:00
Berker Peksag
3fc536f1c9
Issue #24857 : Comparing call_args to a long sequence now correctly returns a
...
boolean result instead of raising an exception.
Patch by A Kaptur.
2015-09-09 23:35:25 +03:00
Berker Peksag
86b34da5ef
Issue #23004 : mock_open() now reads binary data correctly when the type of read_data is bytes.
...
Initial patch by Aaron Hill.
2015-08-06 13:15:51 +03:00
Robert Collins
ca647ef60a
Issue #21750 : Further fixup to be styled like other mock APIs.
2015-07-24 03:48:20 +12:00
Robert Collins
92b3e06517
Typo fix in mock.patch.
...
Patch from https://github.com/testing-cabal/mock/issues/215
2015-07-17 21:58:36 +12:00
Robert Collins
5329aaa74b
Issue #21750 : mock_open.read_data can now be read from each instance, as it
...
could in Python 3.3.
2015-07-17 20:08:45 +12:00
Robert Collins
b37f43f94b
- Issue #18622 : unittest.mock.mock_open().reset_mock would recurse infinitely.
...
Patch from Nicola Palumbo and Laurent De Buyst.
2015-07-15 11:42:28 +12:00
Berker Peksag
abfaecdfdd
Issue #23004 : mock_open() now reads binary data correctly when the type of read_data is bytes.
...
Initial patch by Aaron Hill.
2015-08-06 13:16:52 +03:00
Robert Collins
88ba360c88
Issue #21750 : Further fixup to be styled like other mock APIs.
2015-07-24 03:48:45 +12:00
Robert Collins
1a80081272
Typo fix in mock.patch.
...
Patch from https://github.com/testing-cabal/mock/issues/215
2015-07-17 22:00:28 +12:00
Robert Collins
4838717b53
Issue #21750 : mock_open.read_data can now be read from each instance, as it
...
could in Python 3.3.
2015-07-17 20:10:23 +12:00
Robert Collins
76d508b5d4
- Issue #18622 : unittest.mock.mock_open().reset_mock would recurse infinitely.
...
Patch from Nicola Palumbo and Laurent De Buyst.
2015-07-15 11:49:43 +12:00
Robert Collins
f58f88c4c7
Issue #23661 : unittest.mock side_effects can now be exceptions again.
...
This was a regression vs Python 3.4. Patch from Ignacio Rossi
2015-07-14 13:51:40 +12:00
Łukasz Langa
a468db9b0b
Issue #23310 : Fix MagicMock's initializer to work with __methods__.
...
Behavior equivalent to m.configure_mock(). Patch by Kasia Jachim.
2015-04-13 23:12:42 -07:00
Łukasz Langa
5f6684efe0
Issue #23310 : Fix MagicMock's initializer to work with __methods__.
...
Behavior equivalent to m.configure_mock(). Patch by Kasia Jachim.
2015-04-14 00:12:57 -07:00
Berker Peksag
7aaa85932c
Issue #23568 : Add rdivmod support to MagicMock() objects.
...
Patch by Håkan Lövdahl.
2015-03-15 01:57:38 +02:00
Berker Peksag
a785dece57
Issue #23568 : Add rdivmod support to MagicMock() objects.
...
Patch by Håkan Lövdahl.
2015-03-15 01:51:56 +02:00
Berker Peksag
9bd8af788d
Issue #23581 : Add matmul support to MagicMock.
...
Patch by Håkan Lövdahl.
2015-03-12 20:42:48 +02:00
Serhiy Storchaka
08448a1f4d
Issue #23326 : Removed __ne__ implementations. Since fixing default __ne__
...
implementation in issue #21408 they are redundant.
2015-01-31 12:05:05 +02:00
Victor Stinner
eb1a995a7c
Issue #22823 : Fix typo in unittest/mock.py
2014-12-11 22:25:49 +01:00
Serhiy Storchaka
c02d188a84
Issue #22823 : Use set literals instead of creating a set from a list.
...
Fixed an output of sets in examples.
2014-12-11 10:28:14 +02:00
Kushal Das
a37b958d65
Closes #21270 : We now override tuple methods in mock.call objects.
2014-09-16 18:33:37 +05:30
Kushal Das
047f14c3c6
Closes #21256 : Printout of keyword args in deterministic order in mock calls.
...
Printout of keyword args should be in deterministic order in
a mock function call. This will help to write better doctests.
2014-06-09 13:45:56 +05:30
Michael Foord
ebc1a30d55
Closes issue 21239. unittest.mock.patch.stopall() did not work deterministically when the same name was patched multiple times.
2014-04-15 17:21:08 -04:00
Kushal Das
484f8a875b
Closes Issue 21222.
...
Passing name keyword argument to mock.create_autospec now works.
2014-04-16 01:05:50 +05:30
Kushal Das
68290f4895
Removes unused varargs and varkwargs from assert_not_called().
2014-04-17 01:54:07 +05:30
Kushal Das
8af9db3e4f
Closes Issue 21262: New method assert_not_called for Mock.
...
It raises AssertionError if the mock has been called.
2014-04-17 01:36:14 +05:30
Kushal Das
8c14534df6
Closes Issue 21238: New keyword argument `unsafe` to Mock.
...
It raises `AttributeError` incase of an attribute startswith assert
or assret.
2014-04-16 23:32:21 +05:30
Michael Foord
15f2d1775e
Merge
2014-04-15 17:22:22 -04:00
Kushal Das
5d1f6c3b15
Merge
2014-04-16 01:22:52 +05:30
Michael Foord
fddcfa27fa
Closes issue 17660. You no longer need to explicitly pass create=True when patching builtin names.
2014-04-14 16:25:20 -04:00
Michael Foord
01bafdcccc
Issue 17826. Setting an iterable side_effect on a mock created by create_autospec now works
2014-04-14 16:09:42 -04:00
Michael Foord
d2623d7786
Issue 20968. unittest.mock.MagicMock now supports division
2014-04-14 11:23:48 -04:00
Larry Hastings
5c66189e88
Issue #20189 : Four additional builtin types (PyTypeObject,
...
PyMethodDescr_Type, _PyMethodWrapper_Type, and PyWrapperDescr_Type)
have been modified to provide introspection information for builtins.
Also: many additional Lib, test suite, and Argument Clinic fixes.
2014-01-24 06:17:25 -08:00
Andrew Svetlov
8ab1e513c1
Process DEFAULT values in mock side_effect that returns iterator.
...
Patch by Michael Ford.
2013-04-07 16:44:07 +03:00
Andrew Svetlov
8b2cd75bdd
Process DEFAULT values in mock side_effect that returns iterator.
...
Patch by Michael Ford.
2013-04-07 16:42:24 +03:00
Ezio Melotti
89e6b31845
#17504 : merge with 3.3.
2013-03-24 16:10:51 +02:00
Ezio Melotti
31a7835df8
#17504 : remove duplicated sentence. Patch by Radu Voicilas.
2013-03-24 16:10:24 +02:00
Michael Foord
04cbe0c35b
Closes issue 17467. Add readline and readlines support to unittest.mock.mock_open
2013-03-19 17:22:51 -07:00
Terry Jan Reedy
8b53559a89
Merge with 3.3, issue #17047 : remove doubled words added in 3.3,
...
as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 18:36:38 -04:00
Terry Jan Reedy
0f84764a09
Issue #17047 : remove doubled words added in 3.3
...
as reported by Serhiy Storchaka and Matthew Barnett.
2013-03-11 18:34:00 -04:00
Antoine Pitrou
5c64df70b5
Issue #17015 : When it has a spec, a Mock object now inspects its signature when matching calls, so that arguments can be matched positionally or by name.
2013-02-03 00:23:58 +01:00
Michael Foord
28d591ceef
Closes issue 15323. Improve failure message of Mock.assert_called_once_with
2012-09-28 16:15:22 +01:00
Michael Foord
f7c4158057
Adding patch.stopall method to unittest.mock
2012-06-10 20:36:32 +01:00
Michael Foord
75963643b1
Fix exception when calling reset_mock on a mock created with autospec
2012-06-09 17:31:59 +01:00
Nick Coghlan
0b43bcf528
Close #14857 : fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370 , but also updates unittest.mock to workaround that issue
2012-05-27 18:17:07 +10:00
Michael Foord
9cf5c9d85e
Remove incorrect comment
2012-04-21 18:32:56 +01:00
Michael Foord
3af125a4aa
Closes issue 14634. unittest.mock.create_autospec now supports keyword only arguments.
2012-04-21 18:22:28 +01:00
Michael Foord
2cd48738ba
Closes issue 14636. mock objects raise exceptions from an iterable side_effect
2012-04-21 15:52:11 +01:00
Michael Foord
0682a0c0a9
Minor docstring / docs corrections for unittest.mock
2012-04-13 20:51:20 +01:00
Michael Foord
656319e58d
Make unittest.mock.create_autospec resilient against AttributeError on original object
2012-04-13 17:39:16 +01:00
Michael Foord
c287062fcf
unittest.mock.PropertyMock return value and attributes are now standard MagicMocks
2012-04-13 16:57:22 +01:00
Michael Foord
aa8ec7e076
Fix unittest.mock.patch docstring
2012-03-28 15:41:28 +01:00
Michael Foord
54b3db8c84
Minor unittest.mock.patch doc / docstring improvement
2012-03-28 15:08:08 +01:00
Michael Foord
0340ea77d1
unittest.mock: removed another bit of Python 2 only code
2012-03-25 23:27:12 +01:00
Michael Foord
944e02d055
Adding unittest.mock documentation
2012-03-25 23:12:55 +01:00
Michael Foord
e58a562d93
unittest.mock: a mock created by patch with a spec as the list argument will be callable if __call__ is in the spec
2012-03-25 19:53:18 +01:00
Michael Foord
fb5d0a78cf
unittest.mock: remove another piece of Python 2 specific code
2012-03-25 19:35:22 +01:00
Michael Foord
1ab27c6fde
Remove more Python 2 code from unittest.mock (obsolete function attributes)
2012-03-25 19:16:10 +01:00
Michael Foord
0dccf657b5
Minor changes to the unittest.mock.mock_open helper
2012-03-25 19:11:50 +01:00
Michael Foord
99254730b2
Addition of docstrings to unittest.mock helpers
2012-03-25 19:07:33 +01:00
Michael Foord
a74561a56d
unittest.mock: set file_spec on first use
2012-03-25 19:03:13 +01:00
Michael Foord
50a8c0ef5d
Support subclassing unittest.mock._patch and fix various obscure bugs around patcher spec arguments
2012-03-25 18:57:58 +01:00
Michael Foord
313f85f0ca
unittest.mock.MagicMock objects are now unorderable by default
2012-03-25 18:16:07 +01:00
Michael Foord
d7c65e2807
Removed XXX from unittest.mock docstring and switch to a nicer try...except...finally
2012-03-14 14:56:54 -07:00
Michael Foord
a74b3aa0cc
Remove more Python 2 compatibility cruft from unittest.mock
2012-03-14 14:40:22 -07:00
Michael Foord
c17adf4151
Remove Python 2 compatibility cruft from unittest.mock
2012-03-14 13:30:29 -07:00
Michael Foord
345266aa7e
PEP 417: Adding unittest.mock
2012-03-14 12:24:34 -07:00