mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Get mock coverage back to 100% (GH-18228)
* use the `: pass` and `: yield` patterns for code that isn't expected to ever be executed. * The _Call items passed to _AnyComparer are only ever of length two, so assert instead of if/else * fix typo * Fix bug, where stop-without-start patching dict blows up with `TypeError: 'NoneType' object is not iterable`, highlighted by lack of coverage of an except branch. * The fix for bpo-37972 means _Call.count and _Call.index are no longer needed. * add coverage for calling next() on a mock_open with readline.return_value set. * __aiter__ is defined on the Mock so the one on _AsyncIterator is never called.
This commit is contained in:
parent
a327677905
commit
db5e86adbc
4 changed files with 35 additions and 54 deletions
|
@ -770,6 +770,14 @@ class PatchTest(unittest.TestCase):
|
|||
self.assertEqual(d, original)
|
||||
|
||||
|
||||
def test_patch_dict_stop_without_start(self):
|
||||
d = {'foo': 'bar'}
|
||||
original = d.copy()
|
||||
patcher = patch.dict(d, [('spam', 'eggs')], clear=True)
|
||||
self.assertEqual(patcher.stop(), False)
|
||||
self.assertEqual(d, original)
|
||||
|
||||
|
||||
def test_patch_dict_class_decorator(self):
|
||||
this = self
|
||||
d = {'spam': 'eggs'}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue