[core] Still refactoring the core behaviour of bags, starting to be much simpler.
This commit is contained in:
committed by
Romain Dorgueil
parent
f18889830b
commit
9a54f7b4aa
30
tests/util/test_collections.py
Normal file
30
tests/util/test_collections.py
Normal 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')
|
||||
Reference in New Issue
Block a user