[core] Still refactoring the core behaviour of bags, starting to be much simpler.

This commit is contained in:
Romain Dorgueil
2017-10-23 21:18:02 +02:00
committed by Romain Dorgueil
parent f18889830b
commit 9a54f7b4aa
22 changed files with 437 additions and 262 deletions

View File

@ -0,0 +1,30 @@
from bonobo.util import sortedlist, ensure_tuple
from bonobo.util.collections import tuplize
def test_sortedlist():
l = sortedlist()
l.insort(2)
l.insort(1)
l.insort(3)
l.insort(2)
assert l == [1, 2, 2, 3]
def test_ensure_tuple():
assert ensure_tuple('a') == ('a', )
assert ensure_tuple(('a', )) == ('a', )
assert ensure_tuple(()) is ()
def test_tuplize():
tuplized_lambda = tuplize(lambda: [1, 2, 3])
assert tuplized_lambda() == (1, 2, 3)
@tuplize
def some_generator():
yield 'c'
yield 'b'
yield 'a'
assert some_generator() == ('c', 'b', 'a')