MCPcopy Index your code
hub / github.com/python/cpython / test_next_data

Method test_next_data

Lib/test/test_unittest/testmock/testwith.py:236–248  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

234 next(h)
235
236 def test_next_data(self):
237 # Check that next will correctly return the next available
238 # line and plays well with the dunder_iter part.
239 mock = mock_open(read_data='foo\nbar\nbaz\n')
240 with patch('%s.open' % __name__, mock, create=True):
241 h = open('bar')
242 line1 = next(h)
243 line2 = next(h)
244 lines = [l for l in h]
245 self.assertEqual(line1, 'foo\n')
246 self.assertEqual(line2, 'bar\n')
247 self.assertEqual(lines[0], 'baz\n')
248 self.assertEqual(h.readline(), '')
249
250 def test_readlines_data(self):
251 # Test that emulating a file that ends in a newline character works

Callers

nothing calls this directly

Calls 5

mock_openFunction · 0.90
patchFunction · 0.90
openFunction · 0.50
assertEqualMethod · 0.45
readlineMethod · 0.45

Tested by

no test coverage detected