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): ...@@ -16,16 +16,16 @@ def keyvalue(key, value):
def keyvalues(key1, value1, key2, value2): def keyvalues(key1, value1, key2, value2):
""" """
>>> keyvalues(1, 2, 3, 4) >>> sorted(keyvalues(1, 2, 3, 4).items())
{1: 2, 3: 4} [(1, 2), (3, 4)]
""" """
d = {key1:value1, key2:value2} d = {key1:value1, key2:value2}
return d return d
def keyvalues2(key1, value1, key2, value2): def keyvalues2(key1, value1, key2, value2):
""" """
>>> keyvalues2(1, 2, 3, 4) >>> sorted(keyvalues2(1, 2, 3, 4).items())
{1: 2, 3: 4} [(1, 2), (3, 4)]
""" """
d = {key1:value1, key2:value2,} d = {key1:value1, key2:value2,}
return d return d
......
...@@ -11,8 +11,8 @@ def exec_module_scope(): ...@@ -11,8 +11,8 @@ def exec_module_scope():
def exec_func_scope(): def exec_func_scope():
""" """
>>> exec_func_scope() >>> sorted(exec_func_scope().items())
{'a': 'b', 'G': 1234} [('G', 1234), ('a', 'b')]
""" """
d = {} d = {}
exec "d['a'] = 'b'; d['G'] = GLOBAL" exec "d['a'] = 'b'; d['G'] = GLOBAL"
......
...@@ -120,6 +120,6 @@ kwargs = {'c': 0} ...@@ -120,6 +120,6 @@ kwargs = {'c': 0}
@cython.test_assert_path_exists("//PyClassMetaclassNode", "//Py3ClassNode") @cython.test_assert_path_exists("//PyClassMetaclassNode", "//Py3ClassNode")
class Foo3(metaclass=Base3, a=0, b=0, **kwargs): class Foo3(metaclass=Base3, a=0, b=0, **kwargs):
""" """
>>> Foo3.kwargs >>> sorted(Foo3.kwargs.items())
{'a': 0, 'c': 0, 'b': 0} [('a', 0), ('b', 0), ('c', 0)]
""" """
...@@ -3,31 +3,31 @@ __doc__ = u""" ...@@ -3,31 +3,31 @@ __doc__ = u"""
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: () Extra args: ()
Extra keywords: {} Extra keywords: []
>>> s = Swallow("Brian", 42, "African") >>> s = Swallow("Brian", 42, "African")
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: ('African',) Extra args: ('African',)
Extra keywords: {} Extra keywords: []
>>> s = Swallow("Brian", airspeed = 42) >>> s = Swallow("Brian", airspeed = 42)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: () Extra args: ()
Extra keywords: {} Extra keywords: []
>>> s = Swallow("Brian", airspeed = 42, species = "African", coconuts = 3) >>> s = Swallow("Brian", airspeed = 42, species = "African", coconuts = 3)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: () Extra args: ()
Extra keywords: {'coconuts': 3, 'species': 'African'} Extra keywords: [('coconuts', 3), ('species', 'African')]
>>> s = Swallow("Brian", 42, "African", coconuts = 3) >>> s = Swallow("Brian", 42, "African", coconuts = 3)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: ('African',) Extra args: ('African',)
Extra keywords: {'coconuts': 3} Extra keywords: [('coconuts', 3)]
""" """
cdef class Swallow: cdef class Swallow:
...@@ -36,4 +36,4 @@ cdef class Swallow: ...@@ -36,4 +36,4 @@ cdef class Swallow:
print u"Name:", name print u"Name:", name
print u"Airspeed:", airspeed print u"Airspeed:", airspeed
print u"Extra args:", args 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): ...@@ -4,29 +4,29 @@ def swallow(name, airspeed, *args, **kwds):
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: () Extra args: ()
Extra keywords: {} Extra keywords: []
>>> swallow("Brian", 42, "African") >>> swallow("Brian", 42, "African")
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: ('African',) Extra args: ('African',)
Extra keywords: {} Extra keywords: []
>>> swallow("Brian", airspeed = 42) >>> swallow("Brian", airspeed = 42)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: () Extra args: ()
Extra keywords: {} Extra keywords: []
>>> swallow("Brian", airspeed = 42, species = "African", coconuts = 3) >>> swallow("Brian", airspeed = 42, species = "African", coconuts = 3)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: () Extra args: ()
Extra keywords: {'coconuts': 3, 'species': 'African'} Extra keywords: [('coconuts', 3), ('species', 'African')]
>>> swallow("Brian", 42, "African", coconuts = 3) >>> swallow("Brian", 42, "African", coconuts = 3)
Name: Brian Name: Brian
Airspeed: 42 Airspeed: 42
Extra args: ('African',) Extra args: ('African',)
Extra keywords: {'coconuts': 3} Extra keywords: [('coconuts', 3)]
""" """
print u"Name:", name print u"Name:", name
print u"Airspeed:", airspeed print u"Airspeed:", airspeed
print u"Extra args:", args print u"Extra args:", args
print u"Extra keywords:", kwds print u"Extra keywords:", sorted(kwds.items())
__doc__ = u""" __doc__ = u"""
>>> b = B() >>> b = B()
>>> b.t >>> sorted(b.t.items())
{1: ((1, 2, 3),), 2: (1, 2, 3)} [(1, ((1, 2, 3),)), (2, (1, 2, 3))]
""" """
class B: class B:
......
...@@ -5,8 +5,8 @@ cdef struct Point: ...@@ -5,8 +5,8 @@ cdef struct Point:
def test_constructor(x, y, color): def test_constructor(x, y, color):
""" """
>>> test_constructor(1,2,255) >>> sorted(test_constructor(1,2,255).items())
{'y': 2.0, 'x': 1.0, 'color': 255} [('color', 255), ('x', 1.0), ('y', 2.0)]
>>> test_constructor(1,None,255) >>> test_constructor(1,None,255)
Traceback (most recent call last): Traceback (most recent call last):
... ...
...@@ -17,8 +17,8 @@ def test_constructor(x, y, color): ...@@ -17,8 +17,8 @@ def test_constructor(x, y, color):
def test_constructor_kwds(x, y, color): def test_constructor_kwds(x, y, color):
""" """
>>> test_constructor_kwds(1.25, 2.5, 128) >>> sorted(test_constructor_kwds(1.25, 2.5, 128).items())
{'y': 2.5, 'x': 1.25, 'color': 128} [('color', 128), ('x', 1.25), ('y', 2.5)]
>>> test_constructor_kwds(1.25, 2.5, None) >>> test_constructor_kwds(1.25, 2.5, None)
Traceback (most recent call last): Traceback (most recent call last):
... ...
...@@ -29,8 +29,8 @@ def test_constructor_kwds(x, y, color): ...@@ -29,8 +29,8 @@ def test_constructor_kwds(x, y, color):
def test_dict_construction(x, y, color): def test_dict_construction(x, y, color):
""" """
>>> test_dict_construction(4, 5, 64) >>> sorted(test_dict_construction(4, 5, 64).items())
{'y': 5.0, 'x': 4.0, 'color': 64} [('color', 64), ('x', 4.0), ('y', 5.0)]
>>> test_dict_construction("foo", 5, 64) >>> test_dict_construction("foo", 5, 64)
Traceback (most recent call last): 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