[Python-Dev] cpython: Closes issue 17467. Add readline and readlines support to

Gregory P. Smith greg at krypto.org
Wed Mar 20 07:09:22 CET 2013


On Tue, Mar 19, 2013 at 9:44 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:

>
> On 19 Mar 2013, at 17:26, Antoine Pitrou <solipsis at pitrou.net> wrote:
>
> > On Wed, 20 Mar 2013 01:22:58 +0100 (CET)
> > michael.foord <python-checkins at python.org> wrote:
> >> http://hg.python.org/cpython/rev/684b75600fa9
> >> changeset:   82811:684b75600fa9
> >> user:        Michael Foord <michael at voidspace.org.uk>
> >> date:        Tue Mar 19 17:22:51 2013 -0700
> >> summary:
> >>  Closes issue 17467. Add readline and readlines support to
> unittest.mock.mock_open
> >
> > Wasn't it possible to re-use an existing implementation (such as
> > TextIOBase or StringIO) rather than re-write your own?
> >
> > (it's not even obvious your implementation is correct, BTW. How about
> > universal newlines?)
>
> mock_open makes it easy to put a StringIO in place if that's what you
> want. It's just a simple helper function for providing some known data
> *along with the Mock api* to make asserts that it was used correctly. It
> isn't presenting a full file-system. My suggestion to the implementor of
> the patch was that read / readline / readlines be disconnected - but the
> patch provided allows them to be interleaved and I saw no reason to undo
> that.
>
> If users want more complex behaviour (like universal newline support) they
> can use mock_open along with a StringIO.
>

It'd be good to mention that in the unittest.mock.rst docs.


>
> Michael
>
>
> >
> > Regards
> >
> > Antoine.
> >
> >
> > _______________________________________________
> > Python-Dev mailing list
> > Python-Dev at python.org
> > http://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
>
>
> --
> http://www.voidspace.org.uk/
>
>
> May you do good and not evil
> May you find forgiveness for yourself and forgive others
> May you share freely, never taking more than you give.
> -- the sqlite blessing
> http://www.sqlite.org/different.html
>
>
>
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/greg%40krypto.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130319/c0b042e8/attachment-0001.html>


More information about the Python-Dev mailing list