Example #1
0
    def test_init_with_sentinel_args(self):
        a = iter(['1', '2', '3', 'DONE'])
        sentinel = 'DONE'

        def get_next():
            return next(a)
        it = modify_iter(get_next, sentinel, int)
        expected = [1, 2, 3]
        self.assertEqual(expected, [i for i in it])
Example #2
0
    def test_init_with_sentinel_kwargs(self):
        a = iter([1, 2, 3, 4])
        sentinel = 4

        def get_next():
            return next(a)
        it = modify_iter(get_next, sentinel, modifier=str)
        expected = ['1', '2', '3']
        self.assertEqual(expected, [i for i in it])
Example #3
0
    def test_init_with_sentinel_kwargs(self):
        a = iter([1, 2, 3, 4])
        sentinel = 4

        def get_next():
            return next(a)

        it = modify_iter(get_next, sentinel, modifier=str)
        expected = ['1', '2', '3']
        self.assertEqual(expected, [i for i in it])
Example #4
0
    def test_init_with_sentinel_args(self):
        a = iter(['1', '2', '3', 'DONE'])
        sentinel = 'DONE'

        def get_next():
            return next(a)

        it = modify_iter(get_next, sentinel, int)
        expected = [1, 2, 3]
        self.assertEqual(expected, [i for i in it])
Example #5
0
 def test_modifier_rstrip_unicode(self):
     a = [u(''), u('  '), u('  a  '), u('b  '), u('  c'), u('  '), u('')]
     it = modify_iter(a, modifier=lambda s: s.rstrip())
     expected = [u(''), u(''), u('  a'), u('b'), u('  c'), u(''), u('')]
     self.assertEqual(expected, [i for i in it])
Example #6
0
 def test_modifier_rstrip(self):
     a = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     it = modify_iter(a, modifier=lambda s: s.rstrip())
     expected = ['', '', '  a', 'b', '  c', '', '']
     self.assertEqual(expected, [i for i in it])
Example #7
0
 def test_modifier_default(self):
     a = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     it = modify_iter(a)
     expected = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     self.assertEqual(expected, [i for i in it])
Example #8
0
 def test_modifier_rstrip_unicode(self):
     a = [u(''), u('  '), u('  a  '), u('b  '), u('  c'), u('  '), u('')]
     it = modify_iter(a, modifier=lambda s: s.rstrip())
     expected = [u(''), u(''), u('  a'), u('b'), u('  c'), u(''), u('')]
     self.assertEqual(expected, [i for i in it])
Example #9
0
 def test_modifier_rstrip(self):
     a = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     it = modify_iter(a, modifier=lambda s: s.rstrip())
     expected = ['', '', '  a', 'b', '  c', '', '']
     self.assertEqual(expected, [i for i in it])
Example #10
0
 def test_modifier_default(self):
     a = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     it = modify_iter(a)
     expected = ['', '  ', '  a  ', 'b  ', '  c', '  ', '']
     self.assertEqual(expected, [i for i in it])