示例#1
0
    def test_skip_last_having(self):
        ret = Q.range(1, 9).skip_last_having(lambda x: x % 2).to_list()

        self.assertSequenceEqual((1, 2, 3, 4, 5, 6, 7, 8), ret)
示例#2
0
    def test_take_last_having(self):
        ret = Q.range(1, 9).take_last_having(lambda x: x % 2).to_list()

        self.assertSequenceEqual((9, ), ret)
示例#3
0
    def test_skip_last(self):
        ret = Q.range(1, 10).skip_last(3).to_list()

        self.assertSequenceEqual((1, 2, 3, 4, 5, 6, 7), ret)
示例#4
0
    def test_take_last(self):
        ret = Q.range(1, 10).take_last(5).to_list()

        self.assertSequenceEqual((6, 7, 8, 9, 10), ret)
示例#5
0
 def test_where(self):
     ret = Q.range(1, 10).where(lambda x: x > 5).to_list()
     self.assertSequenceEqual([6, 7, 8, 9, 10], ret)
示例#6
0
 def test_select(self):
     ret = Q.range(1, 5).select(lambda x: x * 2).to_list()
     self.assertSequenceEqual([2, 4, 6, 8, 10], ret)
示例#7
0
 def test_range(self):
     ret = Q.range(1, 10).to_list()
     self.assertSequenceEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], ret)
示例#8
0
    def test_zip(self):
        ret = Q.range(1, 10).zip(Q.range(5, 5)).to_list()

        self.assertSequenceEqual([(1, 5), (2, 6), (3, 7), (4, 8), (5, 9)], ret)
示例#9
0
    def test_zip_longest_right_shorter(self):
        ret = Q.range(1, 10).zip_longest(Q.range(5, 5), fill_right=0).to_list()

        self.assertSequenceEqual([(1, 5), (2, 6), (3, 7), (4, 8),
                                  (5, 9), (6, 0), (7, 0), (8, 0), (9, 0),
                                  (10, 0)], ret)
示例#10
0
    def test_zip_longest_fill_right_longer(self):
        ret = Q.range(1, 5).zip_longest(Q.range(5, 10), fill_right=0).to_list()

        self.assertSequenceEqual([(1, 5), (2, 6), (3, 7), (4, 8), (5, 9),
                                  (None, 10), (None, 11), (None, 12),
                                  (None, 13), (None, 14)], ret)
示例#11
0
    def test_zip_longest_fill_left_shorter(self):
        ret = Q.range(1, 10).zip_longest(Q.range(5, 5), fill_left=0).to_list()

        self.assertSequenceEqual([(1, 5), (2, 6), (3, 7), (4, 8), (5, 9),
                                  (6, None), (7, None), (8, None), (9, None),
                                  (10, None)], ret)