Mario Corchero
e131c9720d
Fix `mock.patch.dict` to be stopped with `mock.patch.stopall` ( #17606 )
...
As the function was not registering in the active patches, the mocks
started by `mock.patch.dict` were not being stopped when
`mock.patch.stopall` was being called.
2020-01-24 08:38:32 +00:00
Emmanuel Arias
1d0c5e16ea
bpo-24928: Add test case for patch.dict using OrderedDict (GH -11437)
...
* add test for path.dict using OrderedDict
Co-authored-by: Yu Tomita nekobon@users.noreply.github.com
2020-01-24 08:14:14 +00:00
Elena Oat
cd90a52983
bpo-38669: patch.object now raises a helpful error (GH17034)
...
This means a clearer message is now shown when patch.object is called with two string arguments, rather than a class and a string argument.
2019-12-08 20:14:38 +00:00
Min ho Kim
39d87b5471
Fix typos mostly in comments, docs and test names (GH-15209)
2019-08-30 16:21:19 -04:00
Mario Corchero
04530812e9
bpo-32299: Return patched dict when using patch.dict as a context manager (GH-11062)
2019-05-28 08:53:30 -04:00
Chris Withers
adbf178e49
Mock 100% coverage (GH-13045)
...
This was achieved by:
* moving many pass statements in tests onto their own lines, so they pass line coverage and can match an easy ignore pattern if branch coverage is added later.
* removing code that cannot be reached.
* removing long-disabled tests.
* removing unused code.
* adding tests for uncovered code
It turned out that removing `if __name__ == '__main__'` blocks that run unittest.main() at the bottom of test files was surprisingly contentious, so they remain and can be filtered out with an appropriate .coveragerc.
2019-05-01 23:04:04 +01:00
Chris Withers
49e27f0afb
remove jython support from unittest.mock (GH#13033)
2019-05-01 08:48:44 +01:00
Xtreak
9b21856b0f
bpo-23078: Add support for {class,static}method to mock.create_autospec() (GH-11613)
...
Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
2019-04-22 05:30:23 +03:00
Xtreak
02b84cb1b4
bpo-36366: Return None on stopping unstarted patch object (GH-12472)
...
Return None after calling unittest.mock.patch.object.stop() regardless of whether the object was started. This makes the method idempotent.
https://bugs.python.org/issue36366
2019-03-28 14:08:43 -07:00
Xtreak
a875ea58b2
bpo-35512: Resolve string target to patch.dict decorator during function call GH#12000
...
* Resolve string target to patch.dict during function call
* Add NEWS entry
* Remove unneeded call
* Restore original value for support.target and refactor assertions
* Add extra assertion to verify unpatched dict
2019-02-24 18:54:49 +00:00
Anirudha Bose
3cf74384b5
bpo-33747: Avoid mutating the global sys.modules dict in unittest.mock tests (GH-8520)
2018-12-07 15:30:42 -08: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
Serhiy Storchaka
e437a10d15
Issue #23277 : Remove unused imports in tests.
2016-04-24 21:41:02 +03: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
Michael Foord
15f2d1775e
Merge
2014-04-15 17:22:22 -04:00
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
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
Antoine Pitrou
356bdeb0a1
Issue #19013 : add unittest.main() epilogs to unittest.mock's own test modules
2013-09-13 23:54:01 +02:00
Michael Foord
f7c4158057
Adding patch.stopall method to unittest.mock
2012-06-10 20:36:32 +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
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
ebff097937
And another one... mock import fix.
2012-03-14 13:01:31 -07:00
Michael Foord
0ca9acd1dd
Fix import failure in mock test
2012-03-14 12:38:06 -07:00
Michael Foord
345266aa7e
PEP 417: Adding unittest.mock
2012-03-14 12:24:34 -07:00