[Python-Dev] doctest and pickle
Ethan Furman
ethan at stoneleaf.us
Sat Jun 8 10:47:35 CEST 2013
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 Fruit
>> >>> from pickle import dumps, loads
>> >>> Fruit.tomato is loads(dumps(Fruit.tomato))
>> True
>
> I think that the documentation is there for people.
I agree.
>If you need tests, add them separately,
I have.
> but the documentation should be clear and understandable.
And the example code should be testable.
> 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 something
you might actually do (importing an Enum from another module) is better than two lines showing esoteric workarounds
(importing __main__ and setting an attribute on it).
Apologies if I sound gruff -- it's way past my bedtime. In fact, I'll think I'll go sleep now. :)
--
~Ethan~
More information about the Python-Dev
mailing list