コード例 #1
0
ファイル: test_iterators.py プロジェクト: tlatzko/spmcluster
    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])
コード例 #2
0
ファイル: test_iterators.py プロジェクト: tlatzko/spmcluster
    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])
コード例 #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])
コード例 #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])
コード例 #5
0
ファイル: test_iterators.py プロジェクト: tlatzko/spmcluster
 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])
コード例 #6
0
ファイル: test_iterators.py プロジェクト: tlatzko/spmcluster
 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])
コード例 #7
0
ファイル: test_iterators.py プロジェクト: tlatzko/spmcluster
 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])
コード例 #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])
コード例 #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])
コード例 #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])