diff options
author | Chris Withers <chris@withers.org> | 2020-01-29 16:24:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 16:24:54 +0000 |
commit | db5e86adbce12350c26e7ffc2c6673369971a2dc (patch) | |
tree | 4d0ea04ac823485a1366958f36136fdd0a809726 /Lib/unittest/test/testmock/testmock.py | |
parent | a327677905956ae0b239ff430a1346dfe265709e (diff) | |
download | cpython-git-db5e86adbce12350c26e7ffc2c6673369971a2dc.tar.gz |
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.
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
-rw-r--r-- | Lib/unittest/test/testmock/testmock.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 677346725b..9b9e066cc5 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -1868,6 +1868,11 @@ class MockTest(unittest.TestCase): with self.assertRaises(StopIteration): next(f1) + def test_mock_open_next_with_readline_with_return_value(self): + mopen = mock.mock_open(read_data='foo\nbarn') + mopen.return_value.readline.return_value = 'abc' + self.assertEqual('abc', next(mopen())) + def test_mock_open_write(self): # Test exception in file writing write() mock_namedtemp = mock.mock_open(mock.MagicMock(name='JLV')) |