05.07.18 20:57, Steven D'Aprano пише:
I think that's really clever. Is it too clever? How do you deal with
dicts in doctests?
There was a proposition for adding a doctest option for
order-insensitive matching (like NORMALIZE_WHITESPACE and ELLIPSIS). But
it was rejected because there is a sim
Steven D'Aprano wrote:
> On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote:
>
>> On 05Jul2018 17:57, Steven D'Aprano
>> wrote:
>>>I have a function which returns a dict, and I want to use doctest to
>>>ensure the documentation is correct. So I write a bunch of doctests:
>>>
>>>def func(a
On 06Jul2018 01:43, Steven D'Aprano
wrote:
On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote:
On 05Jul2018 17:57, Steven D'Aprano
wrote:
I have three ways of dealing with this. Which do you prefer?
Option 4:
>>> func(1) == {'a': 1, 'b': 2, 'c': 3}
True
Alas, in reality f
On Thu, 05 Jul 2018 19:56:59 +0100, MRAB wrote:
> What about sorting the items?
>
> def func(arg):
> """blah blah blah
>
> >>> sorted(func(1).items())
> [('a', 1), ('b', 2), ('c', 3)]
> """
Hmmm it still has the disadvantage of putting the emphasis on the
sorted()
On Fri, 06 Jul 2018 09:31:50 +1000, Cameron Simpson wrote:
> On 05Jul2018 17:57, Steven D'Aprano
> wrote:
>>I have a function which returns a dict, and I want to use doctest to
>>ensure the documentation is correct. So I write a bunch of doctests:
>>
>>def func(arg):
>>"""blah blah blah
>>
>>
On 05Jul2018 17:57, Steven D'Aprano
wrote:
I have a function which returns a dict, and I want to use doctest to
ensure the documentation is correct. So I write a bunch of doctests:
def func(arg):
"""blah blah blah
>>> func(1)
{'a': 1, 'b': 2, 'c': 3}
"""
which is correct, *except
On 2018-07-05 18:57, Steven D'Aprano wrote:
I have a function which returns a dict, and I want to use doctest to
ensure the documentation is correct. So I write a bunch of doctests:
def func(arg):
"""blah blah blah
>>> func(1)
{'a': 1, 'b': 2, 'c': 3}
"""
which is correct,
I have a function which returns a dict, and I want to use doctest to
ensure the documentation is correct. So I write a bunch of doctests:
def func(arg):
"""blah blah blah
>>> func(1)
{'a': 1, 'b': 2, 'c': 3}
"""
which is correct, *except* that dict keys have arbitrary order in t