Exemplo n.º 1
0
    def test_init_with_sentinel_kwargs(self):
        a = iter([1, 2, 3, 4])
        sentinel = 4

        def get_next():
            return next(a)

        it = itermod(get_next, sentinel, modifier=str)
        expected = ['1', '2', '3']
        assert expected == [i for i in it]
Exemplo n.º 2
0
    def test_init_with_sentinel_args(self):
        a = iter(['1', '2', '3', 'DONE'])
        sentinel = 'DONE'

        def get_next():
            return next(a)

        it = itermod(get_next, sentinel, int)
        expected = [1, 2, 3]
        assert expected == [i for i in it]
Exemplo n.º 3
0
 def test_modifier_rstrip_unicode(self):
     a = [u(''), u('  '), u('  a  '), u('b  '), u('  c'), u('  '), u('')]
     it = itermod(a, modifier=lambda s: s.rstrip())
     expected = [u(''), u(''), u('  a'), u('b'), u('  c'), u(''), u('')]
     assert expected == [i for i in it]
Exemplo n.º 4
0
 def test_modifier_rstrip(self):
     a = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     it = itermod(a, modifier=lambda s: s.rstrip())
     expected = ['', '', '  a', 'b', '  c', '', '']
     assert expected == [i for i in it]
Exemplo n.º 5
0
 def test_modifier_default(self):
     a = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     it = itermod(a)
     expected = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     assert expected == [i for i in it]