
from unittest import TestCase
from expects import expect, equal, raise_error 

from slender import List

class TestKeepIf(TestCase):

    def test_keep_if_if_func_is_none(self):
        e = List([1, 2, 3, 4, 5])
        expect(e.keep_if(None).to_list()).to(equal([1, 2, 3, 4, 5]))

    def test_keep_if_if_func_is_valid(self):
        e = List([1, 2, 3, 4, 5])
        expect(e.keep_if(lambda item: item > 3).to_list()).to(equal([4, 5]))

    def test_keep_if_if_func_is_invalid_for_all_items(self):
        e = List([1, 2, 3, 4, 5])
        expect(e.keep_if(lambda item: item > 6).to_list()).to(equal([]))

    def test_keep_if_if_func_is_different(self):
        e = List([1, 2, 3, 4])
        expect(lambda: e.keep_if('...')).to(raise_error(TypeError))




[((10, 12, 10, 33), 'slender.List', 'List', ({(10, 17, 10, 32): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', False, 'from slender import List\n'), ((14, 12, 14, 33), 'slender.List', 'List', ({(14, 17, 14, 32): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', False, 'from slender import List\n'), ((18, 12, 18, 33), 'slender.List', 'List', ({(18, 17, 18, 32): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', False, 'from slender import List\n'), ((22, 12, 22, 30), 'slender.List', 'List', ({(22, 17, 22, 29): '[1, 2, 3, 4]'}, {}), '([1, 2, 3, 4])', False, 'from slender import List\n'), ((11, 45, 11, 67), 'expects.equal', 'equal', ({(11, 51, 11, 66): '[1, 2, 3, 4, 5]'}, {}), '([1, 2, 3, 4, 5])', False, 'from expects import expect, equal, raise_error\n'), ((15, 62, 15, 75), 'expects.equal', 'equal', ({(15, 68, 15, 74): '[4, 5]'}, {}), '([4, 5])', False, 'from expects import expect, equal, raise_error\n'), ((19, 62, 19, 71), 'expects.equal', 'equal', ({(19, 68, 19, 70): '[]'}, {}), '([])', False, 'from expects import expect, equal, raise_error\n'), ((23, 44, 23, 66), 'expects.raise_error', 'raise_error', ({(23, 56, 23, 65): 'TypeError'}, {}), '(TypeError)', False, 'from expects import expect, equal, raise_error\n')]