mock_open()().readline() fails at EOF
See original GitHub issueUsing mock (2.0.0), I fell foul of issue 26907. The same fix applied by hand fixes it.
In [1]: import mock
In [2]: o = mock.mock_open(read_data="fred")
In [3]: f = o()
In [4]: f.readline()
Out[4]: 'fred'
In [5]: f.readline()
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
<ipython-input-5-c4ba08551b5f> in <module>()
----> 1 f.readline()
/home/usr/.virtualenvs/dtree/lib/python2.7/site-packages/mock/mock.py in __call__(_mock_self, *args, **kwargs)
1060 # in the signature
1061 _mock_self._mock_check_sig(*args, **kwargs)
-> 1062 return _mock_self._mock_call(*args, **kwargs)
1063
1064
/home/usr/.virtualenvs/dtree/lib/python2.7/site-packages/mock/mock.py in _mock_call(_mock_self, *args, **kwargs)
1119
1120 if not _callable(effect):
-> 1121 result = next(effect)
1122 if _is_exception(result):
1123 raise result
/home//.virtualenvs/dtree/lib/python2.7/site-packages/mock/mock.py in next(obj, _next)
107 if getattr(obj, '__next__', None):
108 return obj.__next__()
--> 109 return _next(obj)
110
111 del _next
StopIteration:
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Issue 26807: mock_open()().readline() fails at EOF
assertEqual(handle.readline(), 'bar') + def test_readlines_after_eof(self): + # Check that readlines does not fail after the end of file + ...
Read more >How to detect EOF when reading a file with readline() in Python?
readline() returns an empty string, the end of the file has been reached, while a blank line is represented by '\n' , a...
Read more >EOF when reading a line || Python Error while using Online IDEs
EOF #eoferror #pythonabout video:ErrorEOf errorEOFErorreof erroreoferrorEOFError : EOF when reading a lineEOF when reading a lineinput() Efo ...
Read more >Python Error Messages : How to Resolve Unexpected EOF
In this tutorial I will be showing you how to deal with ERROR MESSAGES using Python. This is a step-by-step detailed tutorial made...
Read more >Diff - 30d0143^! - platform/external/v8 - Git at Google
Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e, and updates the x64 makefile properly so ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yay! Now in the backport: 1a19afa054c22264e0c53b78e19ee453921aca9c
ok, we need to do another backporting run,