2018-01-18 10:44:25 +00:00
|
|
|
import pytest
|
2018-01-18 10:49:07 +00:00
|
|
|
from pydu.list import uniq, tolist, flatten
|
2017-11-21 05:10:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_uniq():
|
|
|
|
assert uniq([1, 4, 0, 2, 0, 3]) == [1, 4, 0, 2, 3]
|
2018-01-18 10:44:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('obj', ('foo', ['foo']))
|
|
|
|
def test_tolist(obj):
|
|
|
|
assert tolist(obj) == ['foo']
|
2018-01-18 10:49:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_flatten():
|
|
|
|
assert list(flatten([1, 2])) == [1, 2]
|
|
|
|
assert list(flatten([1, [2, 3]])) == [1, 2, 3]
|
|
|
|
assert list(flatten([1, [2, [3, 4]]])) == [1, 2, 3, 4]
|