This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Anvil
Recipients Anvil
Date 2019-05-22.11:19:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1558523947.08.0.447794454948.issue37008@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-05-22 11:19:07Anvilsetrecipients: + Anvil
2019-05-22 11:19:07Anvilsetmessageid: <1558523947.08.0.447794454948.issue37008@roundup.psfhosted.org>
2019-05-22 11:19:07Anvillinkissue37008 messages
2019-05-22 11:19:07Anvilcreate