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 <>
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:
        for line in my_file:

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.
Date User Action Args
2019-05-22 11:19:07Anvilsetrecipients: + Anvil
2019-05-22 11:19:07Anvilsetmessageid: <>
2019-05-22 11:19:07Anvillinkissue37008 messages
2019-05-22 11:19:07Anvilcreate