question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mock_open()().readline() fails at EOF

See original GitHub issue

Using 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:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
cjw296commented, Apr 27, 2019

Yay! Now in the backport: 1a19afa054c22264e0c53b78e19ee453921aca9c

1reaction
rbtcollinscommented, Apr 18, 2017

ok, we need to do another backporting run,

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found