feat: new alternate syntax and switch to black + isort (yeah, maybe not the best time, but that is done).
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from bonobo.util import sortedlist, ensure_tuple
|
||||
from bonobo.util.collections import tuplize, cast
|
||||
from bonobo.util import ensure_tuple, sortedlist
|
||||
from bonobo.util.collections import cast, tuplize
|
||||
|
||||
|
||||
def test_sortedlist():
|
||||
@ -14,20 +14,20 @@ def test_sortedlist():
|
||||
|
||||
|
||||
def test_ensure_tuple():
|
||||
assert ensure_tuple('a') == ('a', )
|
||||
assert ensure_tuple(('a', )) == ('a', )
|
||||
assert ensure_tuple("a") == ("a",)
|
||||
assert ensure_tuple(("a",)) == ("a",)
|
||||
assert ensure_tuple(()) is ()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('tuplize', [tuplize, cast(tuple)])
|
||||
@pytest.mark.parametrize("tuplize", [tuplize, cast(tuple)])
|
||||
def test_tuplize(tuplize):
|
||||
tuplized_lambda = tuplize(lambda: [1, 2, 3])
|
||||
assert tuplized_lambda() == (1, 2, 3)
|
||||
|
||||
@tuplize
|
||||
def some_generator():
|
||||
yield 'c'
|
||||
yield 'b'
|
||||
yield 'a'
|
||||
yield "c"
|
||||
yield "b"
|
||||
yield "a"
|
||||
|
||||
assert some_generator() == ('c', 'b', 'a')
|
||||
assert some_generator() == ("c", "b", "a")
|
||||
|
||||
Reference in New Issue
Block a user