diff options
author | Tim Harder <radhermit@gmail.com> | 2019-02-17 01:46:11 -0600 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2019-02-17 02:11:59 -0600 |
commit | 55b8ef4b5f278feeb12209a1ff08debd3151ae40 (patch) | |
tree | 0b7064278b24669c8ccdb553c81fb3baf8e6f921 /tests/test_iterables.py | |
parent | cli.exceptions: rename CliException to UserException (diff) | |
download | snakeoil-55b8ef4b5f278feeb12209a1ff08debd3151ae40.tar.gz snakeoil-55b8ef4b5f278feeb12209a1ff08debd3151ae40.tar.bz2 snakeoil-55b8ef4b5f278feeb12209a1ff08debd3151ae40.zip |
iterables: add initial partition() method
Diffstat (limited to 'tests/test_iterables.py')
-rw-r--r-- | tests/test_iterables.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_iterables.py b/tests/test_iterables.py index 3caf2a3..61f6e9e 100644 --- a/tests/test_iterables.py +++ b/tests/test_iterables.py @@ -5,7 +5,24 @@ import operator import pytest -from snakeoil.iterables import expandable_chain, caching_iter, iter_sort +from snakeoil.iterables import partition, expandable_chain, caching_iter, iter_sort + + +class TestPartition(object): + + def test_empty(self): + a, b = partition(()) + assert list(a) == [] + assert list(b) == [] + + def test_split(self): + a, b = partition(range(10)) + assert list(a) == [0] + assert list(b) == list(range(1, 10)) + + a, b = partition(range(10), lambda x: x >= 5) + assert list(a) == [0, 1, 2, 3, 4] + assert list(b) == [5, 6, 7, 8, 9] class TestExpandableChain(object): |