Commit 4a009f36 authored by Vitja Makarov's avatar Vitja Makarov

Don't rely on dict items order in doctests, use sorted() instead

parent 725c588d
......@@ -16,16 +16,16 @@ def keyvalue(key, value):
def keyvalues(key1, value1, key2, value2):
"""
>>> keyvalues(1, 2, 3, 4)
{1: 2, 3: 4}
>>> sorted(keyvalues(1, 2, 3, 4).items())
[(1, 2), (3, 4)]
"""
d = {key1:value1, key2:value2}
return d
def keyvalues2(key1, value1, key2, value2):
"""
>>> keyvalues2(1, 2, 3, 4)
{1: 2, 3: 4}
>>> sorted(keyvalues2(1, 2, 3, 4).items())
[(1, 2), (3, 4)]
"""
d = {key1:value1, key2:value2,}
return d
......
......@@ -11,8 +11,8 @@ def exec_module_scope():
def exec_func_scope():
"""
>>> exec_func_scope()
{'a': 'b', 'G': 1234}
>>> sorted(exec_func_scope().items())
[('G', 1234), ('a', 'b')]
"""
d = {}
exec "d['a'] = 'b'; d['G'] = GLOBAL"
......
......@@ -120,6 +120,6 @@ kwargs = {'c': 0}
@cython.test_assert_path_exists("//PyClassMetaclassNode", "//Py3ClassNode")
class Foo3(metaclass=Base3, a=0, b=0, **kwargs):
"""
>>> Foo3.kwargs
{'a': 0, 'c': 0, 'b': 0}
>>> sorted(Foo3.kwargs.items())
[('a', 0), ('b', 0), ('c', 0)]
"""
......@@ -3,31 +3,31 @@ __doc__ = u"""
Name: Brian
Airspeed: 42
Extra args: ()
Extra keywords: {}
Extra keywords: []
>>> s = Swallow("Brian", 42, "African")
Name: Brian
Airspeed: 42
Extra args: ('African',)
Extra keywords: {}
Extra keywords: []
>>> s = Swallow("Brian", airspeed = 42)
Name: Brian
Airspeed: 42
Extra args: ()
Extra keywords: {}
Extra keywords: []
>>> s = Swallow("Brian", airspeed = 42, species = "African", coconuts = 3)
Name: Brian
Airspeed: 42
Extra args: ()
Extra keywords: {'coconuts': 3, 'species': 'African'}
Extra keywords: [('coconuts', 3), ('species', 'African')]
>>> s = Swallow("Brian", 42, "African", coconuts = 3)
Name: Brian
Airspeed: 42
Extra args: ('African',)
Extra keywords: {'coconuts': 3}
Extra keywords: [('coconuts', 3)]
"""
cdef class Swallow:
......@@ -36,4 +36,4 @@ cdef class Swallow:
print u"Name:", name
print u"Airspeed:", airspeed
print u"Extra args:", args
print u"Extra keywords:", kwds
print u"Extra keywords:", sorted(kwds.items())
......@@ -4,29 +4,29 @@ def swallow(name, airspeed, *args, **kwds):
Name: Brian
Airspeed: 42
Extra args: ()
Extra keywords: {}
Extra keywords: []
>>> swallow("Brian", 42, "African")
Name: Brian
Airspeed: 42
Extra args: ('African',)
Extra keywords: {}
Extra keywords: []
>>> swallow("Brian", airspeed = 42)
Name: Brian
Airspeed: 42
Extra args: ()
Extra keywords: {}
Extra keywords: []
>>> swallow("Brian", airspeed = 42, species = "African", coconuts = 3)
Name: Brian
Airspeed: 42
Extra args: ()
Extra keywords: {'coconuts': 3, 'species': 'African'}
Extra keywords: [('coconuts', 3), ('species', 'African')]
>>> swallow("Brian", 42, "African", coconuts = 3)
Name: Brian
Airspeed: 42
Extra args: ('African',)
Extra keywords: {'coconuts': 3}
Extra keywords: [('coconuts', 3)]
"""
print u"Name:", name
print u"Airspeed:", airspeed
print u"Extra args:", args
print u"Extra keywords:", kwds
print u"Extra keywords:", sorted(kwds.items())
__doc__ = u"""
>>> b = B()
>>> b.t
{1: ((1, 2, 3),), 2: (1, 2, 3)}
>>> sorted(b.t.items())
[(1, ((1, 2, 3),)), (2, (1, 2, 3))]
"""
class B:
......
......@@ -5,8 +5,8 @@ cdef struct Point:
def test_constructor(x, y, color):
"""
>>> test_constructor(1,2,255)
{'y': 2.0, 'x': 1.0, 'color': 255}
>>> sorted(test_constructor(1,2,255).items())
[('color', 255), ('x', 1.0), ('y', 2.0)]
>>> test_constructor(1,None,255)
Traceback (most recent call last):
...
......@@ -17,8 +17,8 @@ def test_constructor(x, y, color):
def test_constructor_kwds(x, y, color):
"""
>>> test_constructor_kwds(1.25, 2.5, 128)
{'y': 2.5, 'x': 1.25, 'color': 128}
>>> sorted(test_constructor_kwds(1.25, 2.5, 128).items())
[('color', 128), ('x', 1.25), ('y', 2.5)]
>>> test_constructor_kwds(1.25, 2.5, None)
Traceback (most recent call last):
...
......@@ -29,8 +29,8 @@ def test_constructor_kwds(x, y, color):
def test_dict_construction(x, y, color):
"""
>>> test_dict_construction(4, 5, 64)
{'y': 5.0, 'x': 4.0, 'color': 64}
>>> sorted(test_dict_construction(4, 5, 64).items())
[('color', 64), ('x', 4.0), ('y', 5.0)]
>>> test_dict_construction("foo", 5, 64)
Traceback (most recent call last):
...
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment