[New-bugs-announce] [issue37008] make unittest.mock.mock_open honor next()
Damien Nadé
report at bugs.python.org
Wed May 22 07:19:07 EDT 2019
New submission from Damien Nadé <bugzilla-python at livna.org>:
While we can iterate on a mock_open handle, it is not actually possible to perform a next() on it.
My use case is the following: I have a file with a one-line header that I want to skip. So, roughly, my code is like
with open(filename, 'r') as my_file:
confirm_header(next(my_file))
for line in my_file:
do_something(line)
And while writing a unit test on this code, the handle returned by mock_open(read_data=my_read_data) returns a mock instead of the first line of my_read_data.
----------
components: Library (Lib)
messages: 343177
nosy: Anvil
priority: normal
severity: normal
status: open
title: make unittest.mock.mock_open honor next()
type: enhancement
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37008>
_______________________________________
More information about the New-bugs-announce
mailing list