Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Steven D'Aprano
On 08/06/13 15:18, Stephen J. Turnbull wrote: Ethan Furman writes: Enumerations can be pickled and unpickled:: from enum import Enum class Fruit(Enum): ... tomato = 1 ... banana = 2 ... cherry = 3 ... from pickle

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Ethan Furman
On 06/07/2013 11:45 PM, Steven D'Aprano wrote: On 08/06/13 15:18, Stephen J. Turnbull wrote: Ethan Furman writes: Enumerations can be pickled and unpickled:: from enum import Enum class Fruit(Enum): ... tomato = 1 ... banana = 2 ...

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Serhiy Storchaka
08.06.13 10:03, Ethan Furman написав(ла): Indeed, and it is already in several different ways. But it would be nice to have a pickle example in the docs that worked with doctest. I ended up doing what Barry did: from test.test_enum import Fruit from pickle import dumps, loads

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Ethan Furman
On 06/08/2013 01:07 AM, Serhiy Storchaka wrote: 08.06.13 10:03, Ethan Furman написав(ла): Indeed, and it is already in several different ways. But it would be nice to have a pickle example in the docs that worked with doctest. I ended up doing what Barry did: from test.test_enum import

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Serhiy Storchaka
08.06.13 11:47, Ethan Furman написав(ла): In this case it is better to exclude a code example from doctests or add auxiliary code (i.e. as Steven suggested) to pass the doctest. Are you saying there is something wrong about what I have in place now? I would think that one line showing

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Ethan Furman
On 06/08/2013 03:09 AM, Serhiy Storchaka wrote: 08.06.13 11:47, Ethan Furman написав(ла): In this case it is better to exclude a code example from doctests or add auxiliary code (i.e. as Steven suggested) to pass the doctest. Are you saying there is something wrong about what I have in place

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Olemis Lang
On 6/8/13, Ethan Furman et...@stoneleaf.us wrote: On 06/08/2013 03:09 AM, Serhiy Storchaka wrote: 08.06.13 11:47, Ethan Furman написав(ла): [...] Fair point. But I suppose that if the end-user is running a doc test, it is not too much to require that the other tests be installed as well.

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Łukasz Rekucki
On 8 June 2013 17:41, Ethan Furman et...@stoneleaf.us wrote: On 06/08/2013 03:09 AM, Serhiy Storchaka wrote: Is it possible to add invisible code which doesn't displayed in the resulting documentation, but taken into account by doctest? I have no idea. This is my first time using doctest.

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread R. David Murray
On Sat, 08 Jun 2013 19:54:18 +0200, =?UTF-8?Q?=C5=81ukasz_Rekucki?= lreku...@gmail.com wrote: On 8 June 2013 17:41, Ethan Furman et...@stoneleaf.us wrote: On 06/08/2013 03:09 AM, Serhiy Storchaka wrote: Is it possible to add invisible code which doesn't displayed in the resulting

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Nick Coghlan
On 9 June 2013 04:17, R. David Murray rdmur...@bitdance.com wrote: On Sat, 08 Jun 2013 19:54:18 +0200, =?UTF-8?Q?=C5=81ukasz_Rekucki?= lreku...@gmail.com wrote: On 8 June 2013 17:41, Ethan Furman et...@stoneleaf.us wrote: On 06/08/2013 03:09 AM, Serhiy Storchaka wrote: Is it possible to

Re: [Python-Dev] doctest and pickle

2013-06-08 Thread Ethan Furman
On 06/08/2013 09:21 PM, Nick Coghlan wrote: Using the test suite in the enum docstrings initially is fine. In the future, once we migrate a module like socket to using enum.IntEnum instead of bare integers, it would be appropriate to change the enum docs to reference that rather than the test

[Python-Dev] doctest and pickle

2013-06-07 Thread Ethan Furman
Is there a doctest mailing list? I couldn't find it. I'm try to use doctest to verify my docs (imagine that!) but I'm having trouble with the one that uses pickle (imagine that!). Any advice on how to make it work? Here's the excerpt:

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Olemis Lang
On 6/7/13, Ethan Furman et...@stoneleaf.us wrote: Is there a doctest mailing list? I couldn't find it. JFTR, Testing-in-Python (TiP) ML should be the right target for general purpose questions about testing, considering docs even for unittest and doctest

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Mark Janssen
from pickle import dumps, loads Fruit.tomato is loads(dumps(Fruit.tomato)) True Why are you using is here instead of ==? You're making a circular loop using is -- MarkJ Tacoma, Washington ___ Python-Dev mailing list

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Mark Janssen
On Fri, Jun 7, 2013 at 10:50 AM, Mark Janssen dreamingforw...@gmail.com wrote: from pickle import dumps, loads Fruit.tomato is loads(dumps(Fruit.tomato)) True Why are you using is here instead of ==? You're making a circular loop using is I should add that when you're

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread R. David Murray
On Fri, 07 Jun 2013 10:54:57 -0700, Mark Janssen dreamingforw...@gmail.com wrote: On Fri, Jun 7, 2013 at 10:50 AM, Mark Janssen dreamingforw...@gmail.com wrote: from pickle import dumps, loads Fruit.tomato is loads(dumps(Fruit.tomato)) True Why are you using is here

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Ethan Furman
On 06/07/2013 09:54 AM, Olemis Lang wrote: On 6/7/13, Ethan Furman et...@stoneleaf.us wrote: Is there a doctest mailing list? I couldn't find it. JFTR, Testing-in-Python (TiP) ML should be the right target for general purpose questions about testing, considering docs even for unittest and

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Ethan Furman
On 06/07/2013 10:50 AM, Mark Janssen wrote: from pickle import dumps, loads Fruit.tomato is loads(dumps(Fruit.tomato)) True Why are you using is here instead of ==? I'm using `is` because I'm verifying that the instance returned by `pickle.loads` is the exact same object as

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Ethan Furman
On 06/07/2013 10:54 AM, Mark Janssen wrote: On Fri, Jun 7, 2013 at 10:50 AM, Mark Janssen dreamingforw...@gmail.com wrote: from pickle import dumps, loads Fruit.tomato is loads(dumps(Fruit.tomato)) True Why are you using is here instead of ==? You're making a circular loop

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread PJ Eby
On Fri, Jun 7, 2013 at 1:54 PM, Mark Janssen dreamingforw...@gmail.com wrote: On Fri, Jun 7, 2013 at 10:50 AM, Mark Janssen dreamingforw...@gmail.com wrote: from pickle import dumps, loads Fruit.tomato is loads(dumps(Fruit.tomato)) True Why are you using is here instead of

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Mark Janssen
Why are you using is here instead of ==? I'm using `is` because I'm verifying that the instance returned by `pickle.loads` is the exact same object as the instance fed into `pickle.dumps`. Enum members should be singletons. I see now. That makes sense, but I don't think you'll be able to

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Barry Warsaw
On Jun 07, 2013, at 09:06 AM, Ethan Furman wrote: Oh, and I just realized this is probably why the flufl.enum docs import from a preexisting module instead of creating a new class on the spot. Exactly. ;) -Barry ___ Python-Dev mailing list

Re: [Python-Dev] doctest and pickle

2013-06-07 Thread Barry Warsaw
On Jun 07, 2013, at 02:30 PM, PJ Eby wrote: I don't know if enums *actually* preserve this invariant, but my default expectation of the One Obvious Way would be that enums, being uniquely-named objects that know their name and container, should be considered global objects in the same fashion as

[Python-Dev] doctest and pickle

2013-06-07 Thread Stephen J. Turnbull
Ethan Furman writes: Enumerations can be pickled and unpickled:: from enum import Enum class Fruit(Enum): ... tomato = 1 ... banana = 2 ... cherry = 3 ... from pickle import dumps, loads Fruit.tomato is